如何用SQLyog實現遠端連線MySQL

來源:互聯網
上載者:User

如何用SQLyog實現遠端連線MySQL

1,SQLyog用戶端,用root使用者遠程連結MySQL時,提示“訪問被拒絕”,在網上搜尋了一下原因。

原來是MySQL沒有授權其遠程連結,所以你只能在用戶端裡面連結。

怎麼解決呢?

原表資料

mysql> use mysql

mysql> select Host,User,Password from user ;
+---------------+---------+-------------------------------------------+
| Host | User | Password |
+---------------+---------+-------------------------------------------+
| localhost | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| www | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| 127.0.0.1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| ::1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |

建立一個新使用者

格式:grant 許可權 on 資料庫名.表名 to 使用者@登入主機 identified by "使用者密碼";

grant select,update,insert,delete on *.* to komiles@123.4.56.89 identified by "komiles1234";

執行完上面語句後,再執行

mysql> select Host,User,Password from user ;
+---------------+---------+-------------------------------------------+
| Host | User | Password |
+---------------+---------+-------------------------------------------+
| localhost | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| www | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| 127.0.0.1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| ::1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |
| 123.4.56.89 | komiles | *50663F1ECEAB844897BC272EC1AE7E83F442F649 |
+---------------+---------+-------------------------------------------+

此時,就可以用你剛才建立的使用者進行遠端存取了。

以下是轉載http://www.cnblogs.com/smallstone/archive/2010/04/29/1723838.html

2、實現遠端連線(授權法)

  將host欄位的值改為%就表示在任何用戶端機器上能以root使用者登入到mysql伺服器,建議在開發時設為%。 
  update user set host = ’%’ where user = ’root’;

  將許可權改為ALL PRIVILEGES


mysql> use mysql;
Database changed
mysql> grant all privileges  on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host        | user | password                                  |
+--------------+------+-------------------------------------------+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %            | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)

這樣機器就可以以使用者名稱root密碼root遠端存取該機器上的MySql.

3、實現遠端連線(改表法)

use mysql;

update user set host = '%' where user = 'root';

這樣在遠端就可以通過root使用者訪問Mysql.

SQLyog用戶端無法串連MySQL伺服器案例分析

CentOS 6.3 安裝MySQL與SQLyog串連 

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

本文永久更新連結地址:

相關文章

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.