1. 配置文件my.ini
在安装目录下创建my.ini文件,配置以下内容
[mysql]
default-character-set=utf8
[mysqld]
basedir =D:\DevProgram\MySQL\mysql-5.7.18-winx64
datadir =D:\DevProgram\MySQL\mysql-5.7.18-winx64\data
port = 3306
max_allowed_packet = 2048M
wait_timeout = 1000
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
#安装时,mysql的root用户未设置密码导致,需忽略权限设置root的密码,
#在第一次登陆MySQL需重设一次密码set password=password('123');
skip_grant_tables
2. cd进入D:\DevProgram\MySQL\mysql-5.7.18-winx64\bin,执行以下命令
安装:
mysqld install
初始化:
mysqld --initialize
启动服务:
net start MySQL
设置密码及授权:
mysql -u root -p
use mysql;
update user set authentication_string = password('123') where USER='root' and HOST='localhost';
update user set host='%' where user='root';授权任意ip以root访问
flush privileges;
quit;
首次使用:
1. 注释掉my.ini中skip_grant_tables
2. 重启mysql服务
net stop mysql;
net start mysql;
3. 更改下密码
set password=password('123');