ユーザ用ツール

サイト用ツール


serverapps:db:mysql:connectexternal

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
serverapps:mysql:connectexternal [2017/04/14 05:21] – 外部編集 127.0.0.1serverapps:db:mysql:connectexternal [2021/05/11 02:29] (現在) – ↷ serverapps:mysql:connectexternal から serverapps:db:mysql:connectexternal へページを移動しました。 hayashi
行 1: 行 1:
 ====== 外部ホストからのMySQL接続 ====== ====== 外部ホストからのMySQL接続 ======
-ユーザの確認+===== /usr/local/etc/mysql/my.cnf ===== 
 + 
 +bind-addressは接続を絞るためのものなので外部からのアクセスを許可する場合には外す。((または接続I/FにBindする))((よって、複数指定はできない)) 
 + 
 +**/usr/local/etc/mysql/my.cnf**を編集する 
 +==== 全てのIPで待ち受け ==== 
 + 
 +  # コメントアウト 
 +  # bind-address = 127.0.0.1 
 +  OR 
 +  bind-address = 0.0.0.0 
 + 
 +==== 127.0.0.1 でのみ待ち受け ==== 
 + 
 +  bind-address = 127.0.0.1 
 + 
 + 
 +==== 指定したアドレスで待ち受け ==== 
 + 
 +  bind-address = 192.168.0.XXX 
 + 
 +この場合、mysql -h 127.0.0.1 で接続できない 
 + 
 +==== 保持していないアドレスで待ち受け ==== 
 + 
 +  bind-address = 192.168.168.XXX 
 + 
 +この場合、mysqlが起動しない 
 + 
 +==== 2行書いた ==== 
 + 
 +  bind-address = 192.168.0.XXX 
 +  bind-address = 192.168.0.YYY 
 + 
 +最後が有効 
 + 
 +==== スペース区切り ==== 
 + 
 +  bind-address = 192.168.0.XXX 192.168.0.YYY 
 + 
 +最初が有効 
 + 
 +===== ユーザの確認 ===== 
   mysql> select user,host from mysql.user;   mysql> select user,host from mysql.user;
   +------+-----------------------+   +------+-----------------------+
行 13: 行 56:
   +------+-----------------------+   +------+-----------------------+
  
-存在するデータベースの一覧+===== 存在するデータベースの一覧 ===== 
   mysql> show databases;     mysql> show databases;  
   +--------------------+   +--------------------+
行 25: 行 69:
   +--------------------+   +--------------------+
  
-ユーザ作成+===== ユーザ作成 ===== 
 +  * すべてのホスト 
   mysql> grant all privileges on *.* to user1@"%" identified by 'パスワード' with grant option;   mysql> grant all privileges on *.* to user1@"%" identified by 'パスワード' with grant option;
-LANのみに限定+ 
 +  * LANのみに限定 
   mysql> grant all privileges on dbname.* to user1@"192.168.0.%" identified by 'パスワード' with grant option;   mysql> grant all privileges on dbname.* to user1@"192.168.0.%" identified by 'パスワード' with grant option;
  
-なお、上記だと作成されるのは外部接続のみなので、同様にLocalhostにも作成する。((作成しないと接続できなかった))+  * なお、上記だと作成されるのは外部接続のみなので、同様にLocalhostにも作成する。((作成しないと接続できなかった)) 
   mysql> grant all privileges on dbname.* to user1@"localhost" identified by 'パスワード' with grant option;   mysql> grant all privileges on dbname.* to user1@"localhost" identified by 'パスワード' with grant option;
  
-ユーザ削除+===== ユーザ削除 ===== 
   mysql> drop user 'user'@'localhost';   mysql> drop user 'user'@'localhost';
  
serverapps/db/mysql/connectexternal.1492147294.txt.gz · 最終更新: 2017/04/14 05:21 by 127.0.0.1