Dashuang Du.
Dashuang Du.

study and practice, years of it.

MySql 重置 root 账户密码

MySql 重置 root 账户密码

2016, Oct 28    

1.停止 mysqld 进程

systemctl stop mysqld.service

2.安全模式下进入 mysql

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql

3.更新 root 账户密码

mysql> update mysql.user set password=PASSWORD("new password") where user='root';
mysql> FLUSH PRIVILEGES;

4.重启 mysql

systemctl restart mysqld.service