简体   繁体   中英

MySQL : Recover root password on Ubuntu

If I paste my title into Google I will see this link as my first result.

https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/

So I followed it

service mysql stop 
mysqld_safe --skip-grant-tables &
mysql -uroot

use mysql; 
update user set authentication_string=PASSWORD("123") where User='root'; 
FLUSH PRIVILEGES; 
quit

Trying

mysql -u root -p123

even if I did this

service mysql start
mysql -u root -p123

I kept getting

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Am I forget to restart anything else ? ♂️

It doesn't apply to all MySQL versions. Look for the official document related to your MySQL version https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM