Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
200 views
in Technique[技术] by (71.8m points)

How to reset the root password in MySQL 8.0.11?

I have actually lost my root password and I need to change it. I follow these steps :

  • Step # 1: Stop the MySQL server process.

    Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for a password.

    Step # 3: Connect to the MySQL server as the root user.

that we can found on these website : https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords#recover-mysql-root-password

mysql> use mysql;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("TOOR");
mysql> flush privileges;
mysql> quit

First error, so I tried :

mysql> use mysql;
mysql> update user set password=PASSWORD("TOOR") where User='root';
mysql> flush privileges;
mysql> quit

Always the same error said :

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '("TOO
R") WHERE User='root'' at line 1

How can I resolve this?

question from:https://stackoverflow.com/questions/50691977/how-to-reset-the-root-password-in-mysql-8-0-11

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

as here says:

This function was removed in MySQL 8.0.11

1.if you in skip-grant-tables mode
in mysqld_safe:

UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;

and then, in terminal:

mysql -u root

in mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

2.not in skip-grant-tables mode
just in mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...