更新时间:2018-03-13 17:36:19浏览次数:922+次
今天装好一台VPS的LNMP后登录mysql提示Access denied for user 'root'@'localhost' (using password: YES)错误,怎么试也登不上,难道是密码设错了?没办法只能重置mysql的root密码了。
先停掉mysql服务
/etc/init.d/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/mysql restart
使用新密码登录mysql -uroot -p