Access denied for user 'root'@'localhost' (using password: NO)
- 2019 年 12 月 6 日
- 筆記
初次安裝mysql,net start mysql,然後輸入mysql -u root -p,出現enter password,我直接點擊回車,結果出現如果下錯誤:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)。網上看了很多方法,都是千篇一律的,沒有解決我的問題 使用:set password for 'root'@'localhost' =password(''); flush privileges; 還是不行,當輸入set password for 'root'@'localhost' =password('');時就出現no database seleced錯誤 #1.停止mysql數據庫 /etc/init.d/mysqld stop #2.執行如下命令 mysqld_safe –user=mysql –skip-grant-tables –skip-networking & #3.使用root登錄mysql數據庫 mysql -u root mysql #4.更新root密碼 mysql> update user set authentication_string=password('root') where user='root'; #5.刷新權限 mysql> FLUSH PRIVILEGES; #6.退出mysql mysql> quit #7.重啟mysql /etc/init.d/mysqld restart #8.使用root用戶重新登錄mysql mysql -u root -p
Enter password: <輸入新設的密碼root>
MySql5.6操作時報錯:You must SET PASSWORD before executing this statement解決 mysql> SET PASSWORD = PASSWORD('123456'); Query OK, 0 rows affected (0.03 sec) MySQL> create database roger; Query OK, 1 row affected (0.00 sec) 也就是用mysql> SET PASSWORD = PASSWORD('123456');這句話重新設置一次密碼!