当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)

Unix/Linux
REDHAT企业版LINUX5.0安装过程图解教程
Linux系统下安装phpmyadmin方法
RedHat Enterprise Linux 5下配置Apache+Mysql+Php
Linux和Windows双系统Grub丢失恢复
Linux系统下touch命令的使用方法
linux下面建立GPRS无线MODEM拨号的方法
redhat linux AS4 下配置无线网卡
让Linux操作系统开机默认进入文本模式
Linux文件权限的设置方法与技巧
linux chown与chmod命令的区别
Linux关机命令详细说明
linux系统 加载u盘、光盘、软盘方法
Linux系统下防止 ARP 欺骗_绑定IP地址和MAC地址
Linux系统中Mysql的安装备份与密码恢复
Linux系统下添加新硬盘,分区,格式化相关步骤
Linux系统下编译安装支持NTFS的内核模块
调整Linux磁盘分区的大小的方法
正确关闭Linux计算机的命令和方法
查看Linux系统下Raid信息
Linux下单网卡绑定多IP与多网卡共用单IP 的方法

Unix/Linux 中的 ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-16   浏览: 202 ::
收藏到网摘: n/a

错误描述: Mysql中添加用户之后可能出现登录时提示ERROR 1045 (28000): Access denied for user的错误.删除user.user中值为NULL的,或更新NULL为test 1)delete from user where user is NULL 2)update user set user=‘test‘ where user is NULL.意外的情况: 如果上述方法没有效果,依然出现空用户,则可以利用图形化用户client删除.
在重装了CentOS后,发觉Mysql一直不好用。
# mysqladmin create dbname 命令老是返回mysqladmin: connect to server at ’localhost’ failed
# mysql -u root@localhost 
>create database dbname;  
也同样返回错误ERROR 1045 (28000): Access denied for user ’root’@’localhost’ (using password: NO)
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ’root’@’localhost’ (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password ’newpassword’
Enter password:
mysqladmin: connect to server at ’localhost’ failed
error: ’Access denied for user ’root’@’localhost’ (using password: YES)’
现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
# /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
Enter password: <输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password: <输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!
# mysql -uroot -p
Enter password: <输入/etc/mysql/debian.cnf文件中[client]节提供的密码>
至此,困惑多时的问题解决了!