MySQL root密码忘记怎么办?老男孩MySQL DBA课程

    /    2019-12-11

  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';

(10)

分享至