■質問内容
レンタルサーバを借りて、DBサーバの構築を行っています。
構築したDBに外部から接続が出来ず、どなたか知恵をお貸し頂ければ助かります。
設定でおかしい箇所や、抜けている箇所、試したらいい事、参考出来そうなサイト等、教えて頂ければ助かります。
一通り試して、手詰まり状態となっています。。
■環境
CentOS7.4 、MySQL8.0.20 、借りているサーバはさくらのレンタルサーバでレンタルしています。
自身のPC(Windows10)で使用していたMySQLのバックアップを取得し、バックアップを使用してDBサーバに移行しています。
■試したこと
①外部接続用のユーザ作成
user:admin
host : %
plugin:mysql_native_passward
※hostは特定のIPに絞ったほうが良いと思いますが、現状’%’にしています。
mysql> select user, host, plugin FROM mysql.user; +------------------+-----------+-----------------------+ | user | host | plugin | +------------------+-----------+-----------------------+ | admin | % | mysql_native_password | | mysql.infoschema | localhost | caching_sha2_password | | mysql.session | localhost | caching_sha2_password | | mysql.sys | localhost | caching_sha2_password | | root | localhost | mysql_native_password | +------------------+-----------+-----------------------+
②/etc/my.cnf の設定変更
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove the leading "# " to disable binary logging # Binary logging captures changes between backups and is enabled by # default. It's default setting is log_bin=binlog # disable_log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M # # Remove leading # to revert to previous value for default_authentication_plugin, # this will increase compatibility with older clients. For background, see: # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin default-authentication-plugin=mysql_native_password datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid #20200507 #bind-address = 127.0.0.1 #bind-address = *********自身のIPの為、*にしています。 ~
bind-addressをすべてコメントアウト
default-authentication-plugin=mysql_native_passwordに変更。
③firewall設定
mysql 使用ポート確認
mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.02 sec) コード
サービスで使用しているポート確認
mysql.xml
[root@tk2-229-24163 ~]# cat /usr/lib/firewalld/services/mysql.xml <?xml version="1.0" encoding="utf-8"?> <service> <short>MySQL</short> <description>MySQL Database Server</description> <port protocol="tcp" port="3306"/> </service>
firewallでサービス許可
[root@tk2-229-24163 ~]# firewall-cmd --list-all --zone=public public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client http https mysql ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
【外部からmysqlにアクセスする際のコマンド】
mysql -h <DBサーバIP> -u admin -p
【エラー内容】
ERROR 2003 (HY000): Can't connect to MySQL server on 'DBサーバIP' (10060)
よろしくお願い致します。

回答3件
あなたの回答
tips
プレビュー