MySQL重置密码

mac2022-06-30  108

1.停止mysql服务

sudo service mysql stop

2.安全模式启动

sudo mysqld_safe --skip-grant-tables &

3.重新登录,不输入密码,直接回车

mysql -uroot -p

4.重置密码为root

use mysql; update user set password=password('root') where user='root'; -- 如果执行报错ERROR 1054(42S22) Unknown column 'password' in ‘field list’则是当前mysql版本没有password字段,password改为authentication_string update user set authentication_string=password('root') where user='root'; flush privileges;

5.重启mysql服务

sudo service mysql start

转载于:https://www.cnblogs.com/xLI4n/p/10437403.html

最新回复(0)