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

How to solve the problem that the MySQL password is correct but cannot log in locally 1045 error

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to solve the problem that the MySQL password is correct but cannot log in locally. The article is very detailed and has a certain reference value. Interested friends must finish reading it!

The MySQL password is correct but cannot log in locally

The error is as follows:

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

Solution:

1. Add the method of skipping password in the parameters for starting mysql, as follows:

Vim / etc/my.cnf

And add skip-grant-tables under [mysql]

This is used to skip password problems, but this is not a complete solution.

2. Restart the mysql service

I use the Mysql of Linux system, the sentence is as follows:

View the port number:

Ps aux | grep mysqld

View status:

Systemctl status mysqld

Restart the mysql service

Systemctl restart mysqld

Try to connect:

Mysql-uroot-p123456

Enter the password. You have just set the skip password to be ignored.

The steps are as follows:

[root@localhost ~] # mysql-uroot-p123456mysql > use mysqlDatabase changedmysql > select user,host,password from user where user='root' +-+-- +-- + | user | host | password | +-+-- +- -- + | root |% | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root | localhost.localdomain | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root | 127.0.0.1 | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root |:: 1 | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | + -- + 4 rows in set (0.02 sec) mysql > update user set host='localhost' where user='root' and host='%' Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0mysql > flush privileges;Query OK, 0 rows affected (0.03 sec) mysql > quitBye

OK, exit mysql and restart mysql will solve the problem.

Compare it before and after:

[root@localhost ~] # mysql-uroot-pmysql > use mysql;Database changedmysql > select user,host,password from user where user='root' +-+-- +-- + | user | host | password | +-+-- +- -+ | root | localhost | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root | localhost.localdomain | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root | 127.0.0.1 | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | | root |:: 1 | * 00A51F3F48415C7D4E8908980D443C29C69B60C9 | + -- + 4 rows in set (0.00 sec) mysql > OK! The above is all the contents of this article entitled "how to solve the problem of correct MySQL password but unable to log in locally in 1045". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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