ubuntu mysql问题 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE)解决

时间:2022-08-09 19:18:23
    问题:mysql -uroot -p

    输入设置的密码

    竟然报错了!

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE)

    修改步骤:

    # /etc/init.d/service mysql stop

    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

    # mysql -u root mysql

    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';

    mysql> FLUSH PRIVILEGES;

    mysql> quit

    # /etc/init.d/service mysql start

    # mysql -u root -p

    Enter password:

    mysql>

 

OK!root用户可以成功访问数据库了