1.mysql密码忘记
2.停止mysql
/etc/init.d/mysql stop
3.启动无密登录mysql
前面/usr/local/mysql/bin/,是MySQL安装的目录bin下
/usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
4.进入mysql命令
/usr/local/mysql/bin/mysql -uroot -p
密码:是空,直接按回车键
5.修改密码
MySQL版本是5.7
use mysql;
update user set authentication_string=password('123456') where user='root';
flush privileges;
quit;
6.重启mysql
/etc/init.d/mysql restart
如果以上帮不了你,可以参考下:
https://www.cnblogs.com/liulei-LL/p/7898804.html