本文章來介紹關于mysql啟動提示 access denied for user root@localhost(using password:YES) 解決辦法總結,有需要的朋友可參考本文章.
關鍵是看:Access denied for user 'root'@'localhost' (using password: YES)',從錯誤中可以看出你的權限是對localhost的訪問沒有放開.
于是你可以使用如下命令來放開權限.
解決辦法
1.管理員登陸系統,停止mysql服務或者結束mysqld-nt進程;
2.進入命令行,來到mysql的安裝目錄.假設安裝目錄為 d:mysql , CMD進入命令行;
3.運行 D:Program FilesMySQLMySQL Server 5.5binmysqld-nt --skip-grant-tables啟動mysql,關閉權限的檢查;
4.運行 D:Program FilesMySQLMySQL Server 5.5binmysqladmin -u root flush-privileges password "newpassword" 重設root密碼;
5.重新啟動mysql服務;
命令方式解決
方法一,代碼如下:
- # /data/mysql/bin/mysqladmin -u -p <首先要停止你之前的啟動的mysql.如果停止的時候.也出現1045的錯誤的話那只有kill掉mysql的pid>
- --Vevb.com
- # 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>
解決方法二
首先計入到mysql的客戶端命令行,然后代碼如下:
- grant all privileges on *.* to 'root'@'localhost' identified by '你的密碼' with grant option;
- flush privileges;
執行完這兩條命令之后就可以了.
新聞熱點
疑難解答