1. sudo /etc/init.d/mysql stop 2. sudo pkill mysql 3. sudo mkdir -p /var/run/mysqld 4. sudo chown mysql /var/run/mysqld 5. sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & 6. mysql -uroot 7. flush privileges;
用安全模式登录ROOT账号,用新的的new_password替换原先old_password
1 2 3 4 5 6 7 8 9 10
1. use mysql; 2. update user set plugin='mysql_native_password'where user='root'; 3. MySQL 5.7+ : update user set authentication_string=PASSWORD('new_password') where user='root'; 4. MySQL 5.6- : update user set password=PASSWORD('new_password') where user='root'; 5. If the password conversion function does not work use: SET CREDENTIALS FOR 'root' TO 'new_password'; 5. flush privileges; 6. commit; 7. exit; 8. sudo /etc/init.d/mysql stop 9. sudo /etc/init.d/mysql start