Mysql登陆报错:connect to server at 'localhost' failed

1100阅读 0评论2014-11-30 taohorse
分类:Mysql/postgreSQL

1.现场:

[root@ha02 ~]# mysqladmin -u root password 'root'

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

此时也无法修改密码

2.解决步骤

[root@ha02 ~]# service mysqld stop
 
Stopping mysqld:                                           [  OK  ]
 
[root@ha02 ~]# mysqld_safe --skip-grant-tables &
 
[1] 6249
 
[root@ha02 ~]# 141128 07:13:16 mysqld_safe Logging to '/var/log/mysqld.log'.
 
141128 07:13:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 
[root@ha02 ~]# mysql -uroot -p
 
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, 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, 3 rows affected (0.00 sec)
 
Rows matched: 3  Changed: 3  Warnings: 0
 
  
 
mysql>  flush privileges;
 
Query OK, 0 rows affected (0.00 sec)
 
  
 
mysql> quit
 
Bye

上一篇:python日志记录系统
下一篇:基本操作