Home  >  Article  >  Database  >  ERROR 1045 (28000): Access denied for user 'root&

ERROR 1045 (28000): Access denied for user 'root&

WBOY
WBOYOriginal
2016-06-07 15:43:101015browse

在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>
搞定!

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Irrlicht学习备忘录2 Quake3MapNext article:.2 HOST主桥(2)