MySQL 数据库 ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

My database version is 8.0.28

This error occurred when connecting to the database today

Use the mysql -u root -p command to enter the database and enter the password. If you forget the password, you will be prompted with this

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

How to do it? Reset your password!

  1. First close the mysql service execution command

net stop mysql
  1. To find the bin address of your mysql installation path, you can directly search the service in win10 to find it. After you find it, double-click mysql in the service to find the bin address.

  1. Open the command line with administrator rights and jump to the bin directory path under the installation path. Be careful not to type the wrong path address.

3. Enter the command on the command line to skip the password verification of mysql

./mysqld --console --skip-grant-tables --shared-memory

success! Note that the command to close mysql must be executed before this

4. Open another DOS command window with administrator privileges, enter the login command and click Enter without entering anything.

mysql -u -root -p

5. Use the sql command to jump to the mysql table and change the password to 123

Note the semicolon in command 2

Someone will enter command 2 and get this error

The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

When this error occurs, execute the flush privileges; command and then run command 2.

命令1:use mysql
命令2:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';

6.设置完 输入flush privileges; 进行权限的刷新 注意命令分号

再输入exit 退出

打开新一个命令行使用net start mysql 启动 再输入mysql -u root -p就可以 正常使用密码123登录了

我是乔木 我的公众号:乔木真言

Guess you like

Origin blog.csdn.net/m0_64547949/article/details/129302594