当前位置:Gxlcms > mysql > ERROR1045(28000):Accessdeniedforuser'root&

ERROR1045(28000):Accessdeniedforuser'root&

时间:2021-07-01 10:21:17 帮助过:11人阅读

在centos下,新搭建的mysql环境,直接输入mysql命令,提示如下错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 老师说是权限问题,随后在网上找到解决方法,粘贴在此,以备后用 --------------------------------

在centos下,新搭建的mysql环境,直接输入mysql命令,提示如下错误

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


老师说是权限问题,随后在网上找到解决方法,粘贴在此,以备后用

---------------------------------------------------------------------------------------------------------------------------------------------

mysql -uroot -p
输入设置的密码
竟然报错了!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE)
初始密码是空的,可我设置了密码的阿。
密码留空
还是错误!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
于是重改密码!
# /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/mysqld restart
# mysql -u root -p
Enter password:
mysql>
搞定!

-----------------------------------------------------------------------------------------------------------------------------------------------

人气教程排行