错误代码#1045 Access denied for user 'root'@'localhost' (using password:YES)
############下面是win下面的解決方法#############
遇到MySQL“錯誤代碼#1045 Access denied for user 'root'@'localhost' (using password:YES)” 需要重置root賬號權限密碼,這個一般還真不好解決。
????不過,這幾天調試的時候真的遇到了這種問題,不能跳過,必須解決才能在 本地調試程序源碼,沒辦法,一點點解決吧。
????好在遇到這種問題的情況,大有人在,所以很多就搬現成的,只要能解決問題就行了。
????方法:
????第一點,停止mysql服務,CMD打開DOS窗口,輸入 "net stop mysql ";不過有時候不停止也是無所謂;
????第二點,在CMD命令行窗口,進入MYSQL安裝目錄 比如“E:\APMServ5.2.6\MySQL5.1\bin”(我用的就是APMServer)
????如下圖:
????第三點,在第二點的命令窗口輸入命令為:"mysqld -nt --skip-grant-tables"
如果是linux系統,那么是/etc/mysql/mysql.conf.d/mysqld.cnf的[mysqld]下面加入:
skip-grant-tables(Mysql ?5.7.26,linux 18.10,改完后記得service mysql restart)
?
????作用是,進入mysql安全模式,即當mysql起來后,不用輸入密碼就能進入數據庫。?
????這時候可以進入數據庫后,給自己的數據庫重新設置密碼就可以了!
????
????如果,還是出現1045錯誤的話,繼續執行以下操作
????1.重新打開一個CMD命令行窗口,輸入:"mysql -uroot -p",使用空密碼的方式登錄MySQL(不用輸入密碼,直接按回車)?
????2.輸入以下命令開始修改root用戶的密碼(注意:命令中"mysql.user"中間有個“點”)?
(舊版本mysql)
????"mysql>update mysql.user set password=PASSWORD('新密碼') where User='root'; "
?
(新版本mysql)
mysql> update mysql.user set authentication_string = "appleyuchi" ?where user = "appleyuchi" ;
mysql> update mysql.user set authentication_string = "appleyuchi" ?where user = "root" ;
?
????3.刷新權限表?
????"mysql>flush privileges"?
????4.退出 :"mysql>quit "
?
????搞定,功成身退!
#################################################3
下面是ubuntu下面的解決方案:
mysql -udebian-sys-maint -p
然后使用/etc/mysql/debian.cnf中的密碼登錄
update mysql.user set authentication_string=password('appleyuchi') where user='root';
mysql> GRANT USAGE ON *.* TO 'appleyuchi'@'localhost' IDENTIFIED BY 'appleyuchi' WITH GRANT OPTION;
這了我的用戶名和密碼都是appleyuchi
mysql> FLUSH PRIVILEGES;
mysql>quit
然后:
mysql u -root -p輸入appleyuchi即可登錄
?
?
參考鏈接:
http://blog.lykezhan.com/jishu/biji/2017/0319/224.html?
總結
以上是生活随笔為你收集整理的错误代码#1045 Access denied for user 'root'@'localhost' (using password:YES)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: service不是内部或者外部命令
- 下一篇: P142-144使用Tensorflow