MySQLサーバへの接続確認
ケース
- 社内の検証サーバ上のDB(MySQLサーバ)に接続できない。(リプレイスに失敗していてDBがしんでいたり、サーバの設定変更により接続できないことがちょくちょく発生していて、DBの中身が見られないことがよくある・・・。)
経緯
DBI connect('データベース名:サーバ名:ポート番号','ユーザ名',...) failed: Can't connect to MySQL server on 'サーバ名' (113) at dbi_connect.pl line 171.
対処
$ ping ホスト名 PING ホスト名 (ホスト名) 56(84) bytes of data. 64 bytes from ホスト名: icmp_seq=1 ttl=64 time=0.783 ms (省略) $ mysql -h ホスト名 -u ユーザ名 -p ERROR 2003 (HY000): Can't connect to MySQL server on 'ホスト名' (113)
MySQLサーバへ接続できないことを確認した。プログラムに問題があるわけではないので、サーバ管理者へ連絡し、DBに接続できるようにしていただく。
解決
$ mysql -h ホスト名 -u ユーザ名 -p elcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 46 Server version: 5.6.13-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>