Linux mysql ERROR 1045 解决

Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[root@DB-Server init.d]# /etc/rc.d/init.d/mysqld stop

[root@DB-Server init.d]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

CTRL+C

[root@DB-Server init.d]# mysql -u root mysql

mysql> update user set password=PASSWORD('newpassword')
    -> where user='root' and host='root' or host='localhost';

mysql> flush privileges;

mysql> quit

[root@DB-Server init.d]# /etc/rc.d/init.d/mysqld restart

[root@DB-Server init.d]# mysql -u root -p
Enter password: (输入新密码即可,有可能要多刷几次)
posted @ 2017-06-07 10:34  dyfisgod  阅读(598)  评论(0编辑  收藏  举报