Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the problem of MySQL 8.0 Login Access denied for user'root'@'localhost' (using password: YES) under win10

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Recently started to learn MySQL, the installation is very smooth, according to the online ready-made tutorials can be successfully installed.

But before I happily enter

Mysql-uroot-p

When entering the password again, I encountered this situation.

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

Many solutions have been found online, but there is basically only one, which is added to the mysqld entry in the .ini file.

Skip-grant-tables

Then restart the server and follow the previous steps again (finally, do not enter the password), but still a statement stopped me.

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

Integrated a lot of methods on the Internet, one by one to try, and finally succeeded.

The overall idea is to modify the contents of the .ini configuration file, but in the form of a command line. I don't know if it is because the version iterates to shield the previous method of directly modifying the file. In any case, it is possible to modify it on MySQL 8.0 through command line modification.

Let's get started.

1. Open cmd as an administrator and change to the bin directory of MySQL

two。 Shut down the MySQL server

Net stop mysql

3. Skip the step of entering a password

Mysqld-defaults-file= "D:\ MySQL\ my.ini"-console-skip-grant-tables

(note: the file name and path should match your own)

If a statement similar to a screenshot circle appears, it is successful.

4. Restart the server

Net start mysql

5. Log in to the MySQL server

Mysql-uroot-p

After entering the password, you can log in successfully.

(the number 1 is very similar to the letter l)

It's almost done at this point, but when I type

Show databases

The feedback from MySQL is:

You must reset your password using ALTER USER statement before executing this statement.

My guess is that MySQL believes that the random password provided during installation is not secure and allows the user to reset the password.

Look for it on the Internet, and then find a ready-made way, refer to the article

Passwords never expire.

ALTER USER 'root'@'localhost' IDENTIFIED BY' New password 'PASSWORD EXPIRE NEVER

The password has a time limit.

ALTER USER 'root'@'localhost' IDENTIFIED BY' New password 'PASSWORD EXPIRE

Then log in to the server again and you will be able to operate normally.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report