mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”的处理方法

使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码: 

文件内容:

[client]
host = localhost
user = debian-sys-maint   //用户名
password = Xgsuj2n8rlvw7jUO  //密码
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = Xgsuj2n8rlvw7jUO
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

在命令行输入:

# mysql -udebian-sys-maint -p 

Enter password: <输入[client]节的密码> 

#use mysql

mysql>update user set password=password("123456") where user="root";

mysql>flush privileges;

mysql> quit 

# mysql -uroot -p 

Enter password: <输入新设的密码newpassword> 

mysql> 

到此成功

posted @ 2014-11-29 10:59  tardis  阅读(434)  评论(0编辑  收藏  举报