Get the App
SLTechnology News&Howtos  ›  Database  › 

What if there is a 1045 error in mysql?

Shulou Source: shulou.com Published: 2022-05-31 15:31:23 09月28日 Update

This article is to share with you about what to do if there is a 1045 error in mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

-- mysql5.6. Login appears after installation.

[root@mytest_db usr] # mysql-uroot-p

Enter password:

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

If you prompt for a password problem, and then modify it with the command, the following error will also occur

[root@mytest_db usr] # mysqladmin-u root password 'petrel'

Mysqladmin: connect to server at 'localhost' failed

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

At this time, we need to deal with it in this way.

-- restart the mysql service and use the mysqld_safe method

[root@mytest_db usr] # service mysql stop

Shutting down MySQL... [OK]

[root@mytest_db usr] # mysqld_safe-user=mysql-skip-grant-tables-skip-networking &

[1] 5043

After startup, you can enter directly without a password, and reset the password at this time

[root@mytest_db usr] # mysql-uroot

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with-A

Database changed

Mysql > update user set Password=PASSWORD ('petrel') where user =' root'

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4 Changed: 4 Warnings: 0

Mysql > flush privileges

Query OK, 0 rows affected (0.00 sec)

Mysql > quit

Bye

[root@mytest_db usr] # service mysql restart

At this time, it will be no problem to log in again.

[root@mytest_db data] # mysql-uroot-ppetrel

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 4

Server version: 5.6.19

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

After logging in, you need to set your password again before you can use it.

Mysql > use mysql

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

Mysql > grant all privileges on *. * to root@'localhost' identified by 'petrel'

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

Mysql > set PASSWORD=PASSWORD ('petrel')

Query OK, 0 rows affected (0.00 sec)

-- appears when the user is empty in the mysql.user table

ERROR 1045 (28000): Access denied for user

At this time, you can do the following

Delete these empty users or update to other user names

Delete the value of NULL in user.user, or update NULL to other values, etc.

Mysql > delete from user where user is NULL

Query OK, 1 rows affected (0.00 sec)

Or update to another value

Mysql > update user set user='mytest' where user is NULL

Query OK, 1 rows affected (0.00 sec)

If there are no accessible users in the mysql.user table, it will also appear.

MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)

At this time, we will take the following steps

[root@mytest_db usr] # service mysql stop

Shutting down MySQL... [OK]

[root@mytest_db usr] # mysqld_safe-user=mysql-skip-grant-tables-skip-networking &

[root@mytest_db usr] # mysql-uroot

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > select * from user

Found no users

Mysql > INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost',' username', PASSWORD ('yourpassword'),' Yong Jing Y','Y')

Query OK, 1 row affected, 3 warnings (0.00 sec)

Thank you for reading! This is the end of the article on "what to do if there are 1045 errors in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Time user password error update login how to do content more article problem processing good practical no median command article way method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Shulou Information NVidia Huawei