ユーザ用ツール

サイト用ツール


serverapps:db:mysql:connectexternal

文書の過去の版を表示しています。


外部ホストからのMySQL接続

ユーザの確認

mysql> select user,host from mysql.user;
+------+-----------------------+
| user | host                  |
+------+-----------------------+
| root | 127.0.0.1             |
| root | ::1                   |
|      | localhost             |
| root | localhost             |
|      | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+

存在するデータベースの一覧

mysql> show databases;  
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| synctest           |
| test               |
+--------------------+

ユーザ作成

mysql> grant all privileges on *.* to user1@"%" identified by 'パスワード' with grant option;

LANのみに限定

mysql> grant all privileges on dbname.* to user1@"192.168.0.%" identified by 'パスワード' with grant option;

なお、上記だと作成されるのは外部接続のみなので、同様にLocalhostにも作成する。1)

mysql> grant all privileges on dbname.* to user1@"localhost" identified by 'パスワード' with grant option;

ユーザ削除

mysql> drop user 'user'@'localhost';
1)
作成しないと接続できなかった
serverapps/db/mysql/connectexternal.1492147294.txt.gz · 最終更新: 2017/04/14 05:21 by 127.0.0.1