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

What if there is a 1045 error in mysql?

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

Share

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

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!

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

Wechat

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

12
Report