mysql 5.7 Access denied for user 'root'@'localhost' solution

sudo vim /etc/mysql/debian.cnf

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = Ya6xoKPmeCs2xOJY
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = Ya6xoKPmeCs2xOJY
socket   = /var/run/mysqld/mysqld.sock



mysql -u debian-sys-maint -p
password:Ya6xoKPmeCs2xOJY

mysql> update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';

mysql> flush privileges;
mysql> quit;

 

posted @ 2018-01-05 15:30  佛法无边  阅读(863)  评论(0编辑  收藏  举报