Windows 安装MySQL5.7.0+ 服务


0、获取安装包

1、在bin目录添加My.ini文件,内容如下

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\mysql-5.7.23-win32
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-5.7.23-win32\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

2、安装和启动MySQL

#进入根目录
C:\Windows\System32>d:
#进入bin目录
D:\>cd item\mysql-3306\bin
安装mysqld服务
D:\item\mysql-3306\bin>mysqld install
运行mysqld
D:\item\mysql-3306\bin>mysqld  --initialize
启动mysql
D:\item\mysql-3306\bin>net start mysql

3、获取密码

在“D:\item\mysql-3306\data”下面找到*.err文件,红框已经框出默认密码

(初始化数据库mysqld –initialize –user=root –console)

3、登陆和设置密码

D:\item\mysql-3306\bin>mysql -u root -p #登陆
Enter password: ****** #输入默认密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('huanu'); #设置密码
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM