mysql 完整改密码步骤
1
如果密码不小心忘记了,需要重置密码,请按照一下步骤来
1. vim /etc/my.cnf 加入skip-grant-tables
1
注意5.7版本以上可能是 /etc/mysql/mysql.conf.d/mysqld.cnf 文件
重启mysql
1
/etc/init.d/mysql restart
无密码登录mysql,重设密码 (新版本和旧版本修改密码方式变了,请确定自己的版本)
1
2
3
4
5
6
7
8
9
10
mysql -uroot -p
use mysql
#旧版本
update user set password=PASSWORD(‘123456’) where User='root';
#5.7以后的版本删除了password字段,改为authentication_string
update user set authentication_string=password('123456') where user='root' ;
#如果还不可以请百度搜索 mysql5.7 修改密码