Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:43:10
Original
1017 people have browsed it

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template