1.问题描述
一般这个错误信息是密码错误引起,
因此需要重置密码
2.重置密码
2.1 跳过Mysql的密码认证
重置密码的第一步就是跳过MySQL的密码认证过程,方法如下
[root@izwz91h49n3mj8r232gqwez ~]# vim /etc/my.cnf
加入在 [mysqld]一栏下面加入一行
skip-grant-tables
如下图
2.2 重启一下Mysql服务
[root@izwz91h49n3mj8r232gqwez etc]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
2.3 修改密码
[root@izwz91h49n3mj8r232gqwez etc]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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("root") where user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
到这里 ,root账户就已经重置成新的密码;
2.3 编辑my.cnf,去掉刚才添加的内容,然后重启MySQL
[root@izwz91h49n3mj8r232gqwez etc]# vim my.cnf
如下图 注释掉一行
skip-grant-tables
2.4 重启服务—使得密码登录生效
[root@izwz91h49n3mj8r232gqwez etc]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service