欢迎投稿

今日深度:

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

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


修改密码报异常
mysql> update user set password=password("y1jhcfzX!") where user="root";

异常
[root@ddtest-mysql01 ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


1、修改my.cnf 跳过认证
添加 skip-grant-tables
[root@ddtest-mysql01 ~]# vi /etc/my.cnf
[mysqld]
port=3306
datadir=/mysqldata01/data
pid-file=/mysqldata01/mysql57.pid
socket=/mysqldata01/mysql57.sock
log-error=/mysqldata01/mysql57-err.log
user=mysql

skip-grant-tables

[client]
socket=/mysqldata01/mysql57.sock


2、重启
[root@ddtest-mysql01 ~]# /etc/init.d/mysqld restart
Shutting down MySQL... SUCCESS!
Starting MySQL. SUCCESS!

3、重置密码

[root@ddtest-mysql01 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 Source distribution

Copyright (c) 2000, 2019, 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 mysql.user set password=password('y1jhcfzX!') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set authentication_string=password('y1jhcfzX!') where user='root';
Query OK, 4 rows affected, 1 warning (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


4、my.cnf 跳过认证去掉
把之前添加的skip-grant-tables 去掉或注释再重启,/etc/init.d/mysqld restart

[root@ddtest-mysql01 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.28 Source distribution

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

mysql> select user,host from user;
+-------+-------------+
| user | host |
+-------+-------------+
| root | 127.0.0.1    |
| root | ::1              |
|        | dd-mysq01 |
| root | dd-mysq01 |
|        | localhost |
| root | localhost |
+-------+-------------+
12 rows in set (0.00 sec)

www.htsjk.Com true http://www.htsjk.com/Mysql/38251.html NewsArticle ERROR 1045 (28000): Access denied for user root@localhost (using password: YES),denied 修改密码报异常 mysql update user set password=password("y1jhcfzX!") where user="root"; 异常 [root@ddtest-mysql01 ~]# mysql -uroot -p Enter pas...
相关文章
    暂无相关文章
评论暂时关闭