简体   繁体   中英

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 ? 🤦🏻‍♂️

As MySQL and variants like MariaDB innovate on authentication mechanisms, old internet links longer work.

As such rather than copying an answer and creating another future non-working link, please use the official documentation for the version you are using.

eg the MySQL version https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html

You can switch the manual between MySQL versions with that blue dropdown menu at the right side (note: may change in future).

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