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

Mysql 5. 7 CentOS Access denied for user & # 039: rootstocks: 039; localhoststocks: 039; solutions

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

Share

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

After installing mysql on centOS, I encountered an error when logging in to MYSQL

[root@mysql-server Downloads] # mysql- u root

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

The key is to restart the mysql service with MYSQLD_OPTS= "--skip-grant-tables"

[root@mysql-server Downloads] # systemctl stop mysqld

[root@mysql-server Downloads] # systemctl set-enviroment MYSQLD_OPTS= "--skip-grant-tables"

Unknown operation 'set-enviroment'.

[root@mysql-server Downloads] # systemctl set-environment MYSQLD_OPTS= "--skip-grant-tables"

[root@mysql-server Downloads] # systemctl start mysqld

[root@mysql-server Downloads] # myslq-u root

Bash: myslq: command not found...

Similar command is: 'mysql'

[root@mysql-server Downloads] # mysql- u root

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

Your MySQL connection id is 3

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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 > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | sys |

+-+

4 rows in set (0.06 sec)

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 authentication_string=password ('root') where user =' root'

Query OK, 1 row affected, 1 warning (0.07 sec)

Rows matched: 1 Changed: 1 Warnings: 1

Mysql > flush previleges

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'previleges' at line 1

Mysql > flush priviledges

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledges' at line 1

Mysql > flush privileges

Query OK, 0 rows affected (0.11 sec)

Mysql > quit

Bye

[root@mysql-server Downloads] # systemctl stop mysqld

[root@mysql-server Downloads] # systemctl unset-environment MYSQLD_OPTS

[root@mysql-server Downloads] # systemctl start mysqld

[root@mysql-server Downloads] # mysql- u root-p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.18

Copyright (c) 2000, 2017, 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 >

Reference: https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7

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