MySQL root密码忘记怎么办?

MySQL单实例

1. 跳过授权表登录

mysqld_safe --skip-grant-table --user=mysql &

2. 更改密码

mysql> update mysql.user set password=password('123456') where user='root' and host='localhost';

MySQL多实例

1. 跳过授权表登录 登录指定多实例的socket的文件

mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-table --user=mysql &

mysql -S /data/3306/mysql.sock 登录数据库

2. 更改密码

mysql> update mysql.user set password=password('123456') where user='root' and host='localhost';

猜你喜欢

转载自blog.csdn.net/lmseo5hy/article/details/80776967