啟動了服務(wù)然后在命令行輸入:mysql -u root -p -P3308password:xxxx輸入正確,但是接著就出錯了:ERROR?1045?(28000):?Access?denied?for?user?'root'@'localhost'?(using?password:?YES) ?度娘上找了很多同樣這種問題的,但是仍然解決不了。然后我找到my.ini 文件,在末尾加上了:skip_grant_tables跳過授權(quán)驗證。重新啟動服務(wù),再登錄可以正常登錄,輸入:use mysql;selecte user,host,authentication_string from user where user='root';刪除掉skip_grant_tables重啟mysql就不能正常登錄。實在找不到答案,求大神幫幫忙看看怎么解決?。?!另外,我的mysql版本是5.7
3 回答
已采納

灬紫羽
TA貢獻(xiàn)107條經(jīng)驗 獲得超71個贊
推薦兩種方法,你都可以試試:
sudo?su先取得管理員權(quán)限 ????mysql?-u?root?-p然后輸入你初次安裝mysql設(shè)置的密碼就進(jìn)去了
#1.停止mysql數(shù)據(jù)庫 /etc/init.d/mysqld?stop ? #2.執(zhí)行如下命令 mysqld_safe?--user=mysql?--skip-grant-tables?--skip-networking?& ? #3.使用root登錄mysql數(shù)據(jù)庫 mysql?-u?root?mysql ? #4.更新root密碼 mysql>?UPDATE?user?SET?Password=PASSWORD('newpassword')?where?USER='root'; #最新版MySQL請采用如下SQL: mysql>?UPDATE?user?SET?authentication_string=PASSWORD('newpassword')?where?USER='root'; ? #5.刷新權(quán)限? mysql>?FLUSH?PRIVILEGES; ? #6.退出mysql mysql>?quit ? #7.重啟mysql /etc/init.d/mysqld?restart ? #8.使用root用戶重新登錄mysql mysql?-uroot?-p? Enter?password:?<輸入新設(shè)的密碼newpassword>
第二種方法本人親測可行

添加回答
舉報
0/150
提交
取消