1、无密码登录MySQL
找到MySQL安装目录下的 my.ini 文件。
打开文件找到 [mysqld] 后在下一行添加 skip-grant-tables。
2、登录MySQL服务。
net stop mysql 停止服务器。
net start mysql 启动服务器。
mysql -uroot -p 登录服务器。
显示输入面膜直接回车(Enter)后登录。
3、修改密码
set password for 'root'@'localhost'=password('123456');
4、如果显示没有权限则需要授权。
set global read_only=0;(关掉主库的只读属性)
grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;
flush privileges;
set global read_only=1;(读写属性)
flush privileges;
5、重启数据库
net stop mysql
net start mysql