解決用戶端與遠程伺服器端的串連(mysql) :xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server

來源:互聯網
上載者:User
轉自CSDN,但原帖有不妥之處,我稍微更正了一下.

1.建立一個新使用者floydlee.
[root@rainfish root]# useradd -g mysql floydlee
[root@rainfish root]# mysql
 
2.進入mysql,格式:grant 許可權 on 資料庫名.表名 使用者@登入主機 identified by "使用者密碼";
 grant select,update,insert,delete on *.* to floydlee@10.187.82.130 identified by "floydlee";
   查看結果,執行:
   use mysql;
   select host,user,password from user;
   可以看到在user表中已有剛才建立的floydlee使用者。host欄位表示登入的主機,其值可以用IP,也可用主機名稱,
   將host欄位的值改為%就表示在任何用戶端機器上能以floydlee使用者登入到mysql伺服器,建議在開發時設為%。
   update user set host = '%' where user = 'floydlee';
2、退出 mysql.
[root@rainfish root]#mysqladmin -uroot -p(密碼) reload(若沒有密碼則不用輸入 - p)
[root@rainfish root]#mysqladmin -uroot -p(密碼) shutdown
a.[root@rainfish root]#mysqld_safe --user=root &
記住:對授權表的任何修改都需要重新reload,即執行第a步。
(由於操作完上面兩步已經可以串連了,所以下面的也沒有用,但是還是寫出來供大家參考)
如果經過以上3個步驟還是無法從用戶端串連,請執行以下操作,在mysql資料庫的db表中插入一條記錄:
use mysql;
insert into db values('192.168.88.234','%','xuys','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
update db set host = '%' where user = 'xuys';
重複執行上面的第2步。

另外一個文獻:
MySQL:無法遠程登入MySQL Server

嘗試用MySQL Adminstrator GUI Tool登入MySQL Server,Server卻回複錯誤訊息:Host '60-248-32-13.HINET-IP.hinet.net' is not allowed to connect to this
MySQL server

這個是因為許可權的問題,處理方式如下:
shell>mysql --user=root -p
輸入密碼
mysql>use mysql
mysql>GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[ipadd] identified by '[password]';

[username]:遠程登入的使用者代碼
[db_name]:表示欲開放給使用者的資料庫稱
[password]:遠程登入的使用者密碼
[ipadd]:IP地址或者IP反查後的DNS Name,此例的內容需填入'60-248-32-13.HINET-IP.hinet.net' ,包函上引號(')

(其實就是在遠端伺服器上執行,地址填寫本地主機的ip地址。)

如果希望開放所有許可權的話請執行:
mysql>update user set select_priv='Y' , Insert_priv='Y', Update_priv='Y', delete_priv='Y', Create_priv='Y', Drop_priv='Y',Reload_priv='Y', shutdown_priv='Y', Process_priv='Y', File_priv='Y', Grant_priv='Y', references_priv='Y',Index_priv='Y', Alter_priv='Y', Show_db_priv='Y', Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y', Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y' where user='[username]';

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.