Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-05-31 21:22:58 10月03日 Update

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!

Tags: Password question login error content article service value interest parameter slogan buddy partner way method more step status knowledge system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Tech Info vpn Docker Xiaomi