kstm-su / ictsc_2019_yrfw_pre2

0 stars 0 forks source link

MySQLに繋がりません! #2

Open zazazazazazazaz opened 4 years ago

zazazazazazazaz commented 4 years ago

先輩がMySQLサーバを立てて、新しく運用を開始したらしい。

そのサーバを利用するため、rootパスワードを教えて貰ったため、今までどおりのログインコマンドを試してみた。

$ mysql -uroot -p -h 192.168.0.100 だが、なぜかログインエラーが出てしまい先輩のサーバにアクセスできない。先輩はサーバ上で正しく動いているらしいので、トラブルシューティングのためにそのサーバへのアクセス権限をもらった。

クライアントサーバから上記のコマンドを実行し、rootユーザがログインできるように変更を加え、下記の内容を報告してほしい。

ログインできるようになるためどのような作業を行ったのか なぜログインが行えなかったのか 問題サーバー クライアント

IPアドレス: 192.168.0.101 ユーザー: admin パスワード: USerPw@19 サーバ

IPアドレス: 192.168.0.100 ユーザー: admin パスワード: USerPw@19 DBユーザー: root DBパスワード: root

yoidea commented 4 years ago
create user 'root'@'%' identified by 'root';
alter user 'root'@"%" identified with mysql_native_password by '{password}';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
yoidea commented 4 years ago
mysql> SELECT host, user, plugin FROM mysql.user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
+-----------+------------------+-----------------------+
5 rows in set (0.00 sec)
yoidea commented 4 years ago

/var/log/mysql/error.log

2019-12-07T04:51:42.062860Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 484
2019-12-07T04:51:43.130712Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-12-07T04:51:43.199046Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2019-12-07T04:51:43.260778Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2019-12-07T06:14:18.880524Z 8 [Warning] [MY-010055] [Server] IP address '192.168.0.101' could not be resolved: Name or service not known
2019-12-07T06:43:21.650478Z 15 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
2019-12-07T06:43:44.980830Z 16 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
arsley commented 4 years ago

https://www.s-style.co.jp/blog/2018/07/2112/

arsley commented 4 years ago
mysql> show variables like '%ssl%';
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| have_openssl       | YES             |
| have_ssl           | YES             |
| mysqlx_ssl_ca      |                 |
| mysqlx_ssl_capath  |                 |
| mysqlx_ssl_cert    |                 |
| mysqlx_ssl_cipher  |                 |
| mysqlx_ssl_crl     |                 |
| mysqlx_ssl_crlpath |                 |
| mysqlx_ssl_key     |                 |
| ssl_ca             | ca.pem          |
| ssl_capath         |                 |
| ssl_cert           | server-cert.pem |
| ssl_cipher         |                 |
| ssl_crl            |                 |
| ssl_crlpath        |                 |
| ssl_fips_mode      | OFF             |
| ssl_key            | server-key.pem  |
+--------------------+-----------------+
17 rows in set (0.00 sec)
arsley commented 4 years ago

クライアント側はdisableになってるやんけ

mysql> show variables like '%ssl%';
+---------------+--------------------------------+
| Variable_name | Value                          |
+---------------+--------------------------------+
| have_openssl  | DISABLED                       |
| have_ssl      | DISABLED                       |
| ssl_ca        | /var/lib/mysql/ca.pem          |
| ssl_capath    |                                |
| ssl_cert      | /var/lib/mysql/server-cert.pem |
| ssl_cipher    |                                |
| ssl_crl       |                                |
| ssl_crlpath   |                                |
| ssl_key       | /var/lib/mysql-server-key.pem  |
+---------------+--------------------------------+
9 rows in set (0.01 sec)
arsley commented 4 years ago

次はこれ

root@mysql-client:/etc/mysql# mysql -uroot -p -h 192.168.0.100 --ssl-ca=/var/lib/mysql/ca.pem
Enter password:
ERROR 2026 (HY000): SSL connection error: ASN: bad other signature confirmation
arsley commented 4 years ago

クライアントとサーバで ca.pem が違ったので合わせた

ERROR 1045 (28000): Access denied for user 'root'@'192.168.0.101' (using password: YES)
arsley commented 4 years ago

厳しい

# mysql -uroot -p -h 192.168.0.100 --ssl-ca=/var/lib/mysql/ca.pem --ssl-cert=/var/lib/mysql/server-cert.pem --ssl-key=/var/lib/mysql/server-key.pem
Enter password:
ERROR 2026 (HY000): SSL connection error: unknown error number
arsley commented 4 years ago

諦め