用命令行来登录Mysql时,就会出现这个错误。
Solution
- 停用mysql服务:
[root@Automation ~]# service mysqld stop
- 输入命令:
[root@Automation ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
另打开一个SSH,登入数据库:
1
2
3
4
5[root@Automation ~]# mysql -u root mysql·
mysql> use mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword')where USER='newuser';
mysql> FLUSH PRIVILEGES;
mysql> exit;删除mysqld_safe:
1
2
3
4[root@Automation ~]# ps -A | grep mysql
3297 ? 00:00:00 mysqld_safe
3399 ? 00:00:00 mysqld
[root@Automation ~]# kill -9 3297启用mysql服务:
[root@Automation ~]# service mysqld start
- 登录数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14[root@Automation ~]# mysql -uadmin -padmin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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>