serverapps:db:mysql:connectexternal
文書の過去の版を表示しています。
外部ホストからのMySQL接続
bind-addressは接続を絞るためのものなので外部からのアクセスを許可する場合には外す。1)2)
- /usr/local/etc/mysql/my.cnf
# コメントアウト # bind-address = 127.0.0.1
ユーザの確認
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にも作成する。3)
mysql> grant all privileges on dbname.* to user1@"localhost" identified by 'パスワード' with grant option;
ユーザ削除
mysql> drop user 'user'@'localhost';
serverapps/db/mysql/connectexternal.1615860374.txt.gz · 最終更新: 2021/03/16 02:06 by hayashi