FreeBSDに係わる構築や維持など

MySQL リモート接続を許可する

$ mysql -u root -h 192.168.5.242
ERROR 1130 (00000): Host '192.168.5.242' is not allowed to connect to this MySQL server

データベースごとにリモート接続を許可する必要あるので設定をする。

$ ssh 192.168.5.242
$ mysql -u root -p

mysql> grant all privileges on *.* to test1@'192.168.5.0/255.255.255.0';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+-------+----------------------------+-------------------------------------------+
| user  | host                       | password                                  |
+-------+----------------------------+-------------------------------------------+
| root  | localhost                  |   |
| root  | host1                      |   |
| test1 | localhost                  |   |
| test1 | 192.168.5.0/255.255.255.0 |   |
+-------+----------------------------+-------------------------------------------+
4 rows in set (0.02 sec)

mysql> quit

関連する記事

Write a comment