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

錯(cuò)誤描述: Mysql中添加用戶之后可能出現(xiàn)登錄時(shí)提示ERROR 1045 (28000): Access denied for user的錯(cuò)誤.刪除user.user中值為NULL的,或更新NULL為test 1)delete from user where user is NULL 2)update user set user=‘test‘ where user is NULL.意外的情況: 如果上述方法沒有效果,依然出現(xiàn)空用戶,則可以利用圖形化用戶client刪除.
在重裝了CentOS后,發(fā)覺Mysql一直不好用。
# mysqladmin create dbname 命令老是返回mysqladmin: connect to server at ’localhost’ failed
# mysql -u-root@localhost
>create database dbname;
也同樣返回錯(cuò)誤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)
使用網(wǎng)上介紹的方法修改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)’
現(xiàn)在終于被我找到了解決方法,如下(請先測試方法三,謝謝?。?br />方法一:
# /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: <輸入新設(shè)的密碼newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]節(jié)提供的用戶名和密碼:
# mysql -udebian-sys-maint -p
Enter password: <輸入[client]節(jié)的密碼>
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <輸入新設(shè)的密碼newpassword>
mysql>
方法三:
這種方法我沒有進(jìn)行過測試,因?yàn)槲业膔oot用戶默認(rèn)密碼已經(jīng)被我修改過了,那位有空測試一下,把結(jié)果告訴我,謝謝!
# mysql -uroot -p
Enter password: <輸入/etc/mysql/debian.cnf文件中[client]節(jié)提供的密碼>
至此,困惑多時(shí)的問題解決了!
相關(guān)文章
Linux crontab定時(shí)執(zhí)行任務(wù) 命令格式與詳細(xì)例子
Linux crontab定時(shí)執(zhí)行任務(wù) 命令格式與詳細(xì)例子,大家可以參考下。2017-02-08- 這篇文章主要介紹了zip/unzip壓縮解壓縮命令的使用方法及參數(shù)的說明,需要的朋友可以參考下2013-09-22
- 這里我整理了一份最新、最熱的 Linux 發(fā)行版的下載鏈接,可以讓初學(xué)者能夠快速領(lǐng)略到 Linux 的風(fēng)采。2014-10-31
Linux文件的復(fù)制、刪除和移動(dòng)命令使用說明
Linux文件的復(fù)制、刪除和移動(dòng)命令使用說明,需要的朋友可以參考下。2011-03-25rpm 命令|rpm 安裝|rpm 卸載|rpm 使用|rpm 刪除
在Linux操作系統(tǒng)中,有一個(gè)系統(tǒng)軟件包,它的功能類似于Windows里面的“添加/刪除程序”,但是功能又比“添加/刪除程序”強(qiáng)很多,它就是Red Hat Package Manager2017-09-25在Linux系統(tǒng)下安裝Vmware(虛擬機(jī))圖文教程步驟詳細(xì)介紹
要在Linux下虛擬一個(gè)Windows,經(jīng)過查找些資料,發(fā)現(xiàn)可一用VMware來實(shí)現(xiàn),當(dāng)然還有其他一些虛擬機(jī)可以使用如Win4lin,bochs等2013-08-02- 對于初學(xué)者來說,如何修改linux用戶密碼也不是件容易的事,其實(shí)非常簡單,下面舉例說明: 如果是以root身份登錄,修改root密碼.只要輸入 passwd 就會(huì)出現(xiàn): New password:&nb2009-03-10
Linux chmod命令修改文件與文件夾權(quán)限的命令附實(shí)例
在linux中要修改一個(gè)文件夾或文件的權(quán)限我們需要用到linux chmod命令來做,下面我寫了幾個(gè)簡單的實(shí)例大家可參考一下2013-05-01- 今天終于找到了一篇很好得文章,在Ubuntu下面怎么很方便的安裝eclipse,太好了,下面分享一下2013-11-14
- iostat,用于報(bào)告中央處理器(CPU)統(tǒng)計(jì)信息和整個(gè)系統(tǒng)、適配器、tty 設(shè)備、磁盤和 CD-ROM 的輸入/輸出統(tǒng)計(jì)信息2016-11-23