linux mysql忘記密碼的多種解決或Access denied for user 'root'@'localhost'
更新時間:2009年07月29日 19:07:36 作者:
linux mysql忘記密碼的多種解決方法。
我的系統(tǒng)是ubuntu6.06,最近新裝好的mysql在進(jìn)入mysql工具時,總是有錯誤提示:
# mysql -uroot -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)在終于被我找到了解決方法,如下(請先測試方法三,謝謝?。?
方法一:
# /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)行過測試,因為我的root用戶默認(rèn)密碼已經(jīng)被我修改過了,那位有空測試一下,把結(jié)果告訴我,謝謝!!
# mysql -uroot -p
Enter password: <輸入/etc/mysql/debian.cnf文件中[client]節(jié)提供的密碼>
至此,困惑多時的問題解決了!
# mysql -uroot -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)在終于被我找到了解決方法,如下(請先測試方法三,謝謝?。?
方法一:
# /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)行過測試,因為我的root用戶默認(rèn)密碼已經(jīng)被我修改過了,那位有空測試一下,把結(jié)果告訴我,謝謝!!
# mysql -uroot -p
Enter password: <輸入/etc/mysql/debian.cnf文件中[client]節(jié)提供的密碼>
至此,困惑多時的問題解決了!
相關(guān)文章
mysql存儲過程之循環(huán)語句(WHILE,REPEAT和LOOP)用法分析
這篇文章主要介紹了mysql存儲過程之循環(huán)語句(WHILE,REPEAT和LOOP)用法,結(jié)合實例形式分析了mysql存儲過程循環(huán)語句WHILE,REPEAT和LOOP的原理、用法及相關(guān)操作注意事項,需要的朋友可以參考下2019-12-12
如何解決mysql出現(xiàn)Incorrect string value for co
這篇文章主要介紹了如何解決mysql出現(xiàn)Incorrect string value for column ‘表項‘ at row 1錯誤問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2025-03-03
詳解mysql中字符串轉(zhuǎn)為數(shù)字的三種方法
這篇文章主要為大家詳細(xì)介紹了mysql中字符串轉(zhuǎn)為數(shù)字的三種常用方法,文中的示例代碼講解詳細(xì),具有一定的借鑒價值,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-11-11
什么是分表和分區(qū) MySql數(shù)據(jù)庫分區(qū)和分表方法
這篇文章主要為大家詳細(xì)介紹了MySql數(shù)據(jù)庫分區(qū)和分表方法,告訴大家什么是分表和分區(qū),mysql分表和分區(qū)有什么聯(lián)系,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-02-02
如何使用分區(qū)處理MySQL的億級數(shù)據(jù)優(yōu)化
mysql在查詢上千萬級數(shù)據(jù)的時候,通過索引可以解決大部分查詢優(yōu)化問題。但是在處理上億數(shù)據(jù)的時候,應(yīng)該怎么解決,本文就是用分區(qū)來優(yōu)化一下,感興趣的一起來了解一下2021-06-06

