五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現在的位置: 365建站網 > 365文章 > 解決mysql"Access denied for user'root'@'localhost/IP地址'"的方法

解決mysql"Access denied for user'root'@'localhost/IP地址'"的方法

文章來源:365jz.com     點擊數:15762    更新時間:2017-12-17 09:53   參與評論

最近在工作中遇到一個問題,在創(chuàng)建數據庫后連接數據庫的時候居然報錯了,錯誤代碼是Access denied for user 'root'@'%' to database 'xxx',通過查找相關的資料終于解決了這個問題,所以想著總結下來分享給有需要的朋友們參考學習,下面來一起看看吧。

解決過程

1、創(chuàng)建數據庫

create database mytest; 

2.連接數據庫,報以下錯:

Access denied for user 'root'@'%' to database 'mytest' 

原因:創(chuàng)建完數據庫后,需要進行授權,在本地訪問一般不會存在這個問題。

3.授權數據庫操作

grant all on xxx.* to 'root'@'%' identified by 'password' with grant option; 

其中:xxx代表創(chuàng)建的數據庫; password為用戶密碼,在此為root的密碼。

 


 

在另一臺服務器使用 MySQL-Front鏈接時:

解決方法: 在MySQL服務器上使用root登錄后,執(zhí)行如下SQL語句:

 mysql 登錄命令: >mysql -u root -p;

然后執(zhí)行如下命令:

1. GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
2.FLUSH PRIVILEGES;

執(zhí)行后連接成功:




linux完美解決Mysql的Access denied for user 'root'@'%的'問題
     最近在分配mysql權限時出錯,mysql版本5.6,造成mysql在重新分配權限提示"Access denied for user 'root'@'%",出錯原因reload權限被收回,造成無法重新分配權限,其他類似權限問題也可以參照此方法。
    一·解決辦法
    第一步:停服務
命令行:
/etc/init.d/mysql stop
如果不行,就執(zhí)行下一行:
service mysqld stop
報:
Stopping mysqld:  [  OK  ]


第二步:跳過密碼驗證
執(zhí)行命令行:
# /usr/bin/mysqld_safe --skip-grant-tables
報:
151104 09:07:56 mysqld_safe Logging to '/var/lib/mysql/iZ23dq2wm0jZ.err'.
151104 09:07:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


第三步:無密碼登錄
執(zhí)行命令行:
mysql -u root


第四步:授權
mysql>
grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;
關鍵詞解釋:
root'@'localhost:是用戶
root:是密碼


問題一:發(fā)現無密碼條件下,沒有授權的寫權限
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解決方法:
mysql> set global read_only=0;//(關掉新主庫的只讀屬性)
mysql>flush privileges;
grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;#再次重新授權
mysql>set global read_only=1;//(讀寫屬性)
mysql>flush privileges;
mysql>exit;
(注意刷新是必須項)


第五步:重啟數據庫
service mysqld stop
報:
Stopping mysqld:  [  OK  ]


service mysqld start
報:
Starting mysqld:  [  OK  ]
或者
service mysqld restart


如對本文有疑問,請?zhí)峤坏浇涣髡搲瑥V大熱心網友會為你解答??! 點擊進入論壇

發(fā)表評論 (15762人查看0條評論)
請自覺遵守互聯網相關的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學習

業(yè)務咨詢

· 技術支持
· 服務時間:9:00-18:00
365建站網二維碼

Powered by 365建站網 RSS地圖 HTML地圖

copyright © 2013-2024 版權所有 鄂ICP備17013400號