Raspberry PiでLAMP環境構築 その2
みなさんこんにちは
続きです。
phpmyadminをWebブラウザ上から見ることができました。
では、別の端末からコマンドラインで入ってみましょう。
クライアント端末
・Windows 10 Pro 64bit
・MySQL バージョン 15.1 Distrib 10.1.13-MariaDB
サーバー側
・ユーザーはphpmyadminで作成
・ホスト名は%に設定(どこからでもアクセス可)
・IPアドレスは仮に192.169.1.1としておく
Windows CMD
>mysql -u phpmyadmin -h 192.168.1.1 --port=3306 -p
Enter password : **********
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.1 (10061 "Unknown error")
ふぁ!?
なんだこのエラーは!?
とりあえずエラー番号10061を検索、、、
外部から接続するにはbind-addressを設定する必要があるようだ。
Raspberry Pi の中にある
/etc/mysql/my.cnf
を編集
[mysqld]
bind-address = 192.168.1.1
自身に付与されているIPアドレスを指定すればよいらしい
これで
mysql -u remoteonly -h 192.168.1.1 -P 3306 -p
Enter password: **********
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
ようやく接続できた。
とりあえずここまで。
おわります。