MySQL設定 · 2 min read · Jan 29, 2026

1つのphpMyAdminインストールから複数のMySQLサーバーを管理する(SSL暗号化を使用) - ページ2

3 phpMyAdminの設定

local.example.com:

phpMyAdminの設定を進める前に、まずlocal.example.comからremote.example.comのMySQLサーバーに本当に接続できるか確認しましょう(SSL接続を通じて):

mysql --ssl-ca=/etc/mysql/newcerts/ca-cert.pem --ssl-cert=/etc/mysql/newcerts/client-cert.pem --ssl-key=/etc/mysql/newcerts/client-key.pem -h remote.example.com -u root -p

パスワードを求められ、すべてがうまくいけば、アクセスが許可されます:

root@local:/etc/mysql/newcerts# mysql –ssl-ca=/etc/mysql/newcerts/ca-cert.pem –ssl-cert=/etc/mysql/newcerts/client-cert.pem –ssl-key=/etc/mysql/newcerts/client-key.pem -h remote.example.com -u root -p
パスワードを入力してください:
MySQLモニターへようこそ。コマンドは;または\gで終了します。
あなたのMySQL接続IDは101です
サーバーバージョン:5.5.24-8-log(Debian)

Copyright (c) 2000, 2011, Oracleおよびその関連会社。全著作権所有。

OracleはOracle Corporationおよびその関連会社の登録商標です。他の名前はそれぞれの所有者の商標である可能性があります。

'help;'または'\h'を入力してヘルプを表示します。'\c'を入力して現在の入力文をクリアします。
mysql>

終了するには

quit;

を入力します。

さて、phpMyAdminの設定に移ります - すでにphpMyAdminを使用してローカルMySQLサーバーに接続できることを前提とし、次にSSLを使用してremote.example.comにも接続できるように設定したいと思います(phpMyAdminのログイン画面には、接続したいサーバーを選択できるドロップダウンメニューがあります)。

phpMyAdminがSSLを使用してリモートMySQLサーバーと通信できるようにする前に、少しソースを修正する必要があります - mysqli.dbi.lib.phpを開きます(DebianおよびUbuntuの場合、aptを通じてphpMyAdminをインストールしている場合は、/usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.phpです):

vi /usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php

次のセクションを見つけます…

| | [...] /* オプションでSSLを有効にする */ if ($GLOBALS['cfg']['Server']['ssl'] && defined('MYSQLI_CLIENT_SSL')) { $client_flags |= MYSQLI_CLIENT_SSL; } [...] | |

… そして次のように修正します:

| | [...] /* オプションでSSLを有効にする */ if ($GLOBALS['cfg']['Server']['ssl'] && defined('MYSQLI_CLIENT_SSL')) { mysqli_ssl_set($link, $GLOBALS['cfg']['Server']['key'], $GLOBALS['cfg']['Server']['cert'], $GLOBALS['cfg']['Server']['ca'], $GLOBALS['cfg']['Server']['capath'], $GLOBALS['cfg']['Server']['cipher']); $client_flags |= MYSQLI_CLIENT_SSL; } [...] | |

次にconfig.inc.phpを開きます - Debian/Ubuntuでaptを通じてphpMyAdminをインストールしている場合は、/etc/phpmyadmin/config.inc.phpです:

vi /etc/phpmyadmin/config.inc.php 

次のセクションを見つけます:

| | [...] /* dbconfig-commonに従って設定(有効な場合) */ if (!empty($dbname)) { /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ if (empty($dbserver)) $dbserver = 'localhost'; $cfg['Servers'][$i]['host'] = $dbserver; if (!empty($dbport) || $dbserver != 'localhost') { $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['port'] = $dbport; } //$cfg['Servers'][$i]['compress'] = false; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; /* オプション:高度な機能のためのユーザー */ $cfg['Servers'][$i]['controluser'] = $dbuser; $cfg['Servers'][$i]['controlpass'] = $dbpass; /* オプション:高度なphpMyAdmin機能 */ $cfg['Servers'][$i]['pmadb'] = $dbname; $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; $cfg['Servers'][$i]['relation'] = 'pma_relation'; $cfg['Servers'][$i]['table_info'] = 'pma_table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma_column_info'; $cfg['Servers'][$i]['history'] = 'pma_history'; $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; $cfg['Servers'][$i]['tracking'] = 'pma_tracking'; $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; /* パスワードなしのアカウントへのログインを有効にするには、以下をコメント解除します。 * 関連するセキュリティリスクに注意してください。 */ // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; /* 残りの設定のために次のサーバーに進む */ $i++; } [...] | |

それに続いて、localhost(= local.example.com)のために次のセクションを追加します:

| | [...] /* localhost.example.com */ /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['hide_db'] = '(information_schema|performance_schema|test)'; $i++; [...] | |

($cfg[‘Servers’][$i][‘hide_db’]行では、phpMyAdminに表示したくないすべてのデータベースを指定できます - 例えばinformation_schema、performance_schema、testなど。)

そして、remote.example.comのために次のセクションを追加します:

| | [...] /* remote.example.com */ /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ $cfg['Servers'][$i]['host'] = 'remote.example.com'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['ssl'] = true; $cfg['Servers'][$i]['key'] = '/etc/mysql/newcerts/client-key.pem'; $cfg['Servers'][$i]['cert'] = '/etc/mysql/newcerts/client-cert.pem'; $cfg['Servers'][$i]['ca'] = '/etc/mysql/newcerts/ca-cert.pem'; $cfg['Servers'][$i]['capath'] = NULL; $cfg['Servers'][$i]['cipher'] = NULL; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['hide_db'] = '(information_schema|performance_schema|test)'; $i++; [...] | |

$cfg[‘Servers’][$i][‘extension’]にmysqliを使用し、$cfg[‘Servers’][$i][‘ssl’]をtrueに設定し、SSLファイルを上記のように指定してください。私の完全なサーバーセクションは次のようになります:

| | [...] /* dbconfig-commonに従って設定(有効な場合) */ if (!empty($dbname)) { /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ if (empty($dbserver)) $dbserver = 'localhost'; $cfg['Servers'][$i]['host'] = $dbserver; if (!empty($dbport) || $dbserver != 'localhost') { $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['port'] = $dbport; } //$cfg['Servers'][$i]['compress'] = false; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; /* オプション:高度な機能のためのユーザー */ $cfg['Servers'][$i]['controluser'] = $dbuser; $cfg['Servers'][$i]['controlpass'] = $dbpass; /* オプション:高度なphpMyAdmin機能 */ $cfg['Servers'][$i]['pmadb'] = $dbname; $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; $cfg['Servers'][$i]['relation'] = 'pma_relation'; $cfg['Servers'][$i]['table_info'] = 'pma_table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma_column_info'; $cfg['Servers'][$i]['history'] = 'pma_history'; $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; $cfg['Servers'][$i]['tracking'] = 'pma_tracking'; $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; /* パスワードなしのアカウントへのログインを有効にするには、以下をコメント解除します。 * 関連するセキュリティリスクに注意してください。 */ // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; /* 残りの設定のために次のサーバーに進む */ $i++; } /* localhost.example.com */ /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['hide_db'] = '(information_schema|performance_schema|test)'; $i++; /* remote.example.com */ /* 認証タイプ */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* サーバーパラメータ */ $cfg['Servers'][$i]['host'] = 'remote.example.com'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['ssl'] = true; $cfg['Servers'][$i]['key'] = '/etc/mysql/newcerts/client-key.pem'; $cfg['Servers'][$i]['cert'] = '/etc/mysql/newcerts/client-cert.pem'; $cfg['Servers'][$i]['ca'] = '/etc/mysql/newcerts/ca-cert.pem'; $cfg['Servers'][$i]['capath'] = NULL; $cfg['Servers'][$i]['cipher'] = NULL; /* サーバーにmysqliがある場合はそれを選択 */ $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['hide_db'] = '(information_schema|performance_schema|test)'; $i++; /* サーバー設定の終了 */ [...] | |

これで完了です - phpMyAdminのログイン画面には、接続したいMySQLサーバー(localhostまたはremote.example.com)を選択できるドロップダウンメニューが表示されるはずです。リモートMySQLサーバー(remote.example.comなど)を選択すると、phpMyAdminはSSL接続を通じてそれに接続します。

4 リンク

著者について

ファルコ・ティメは、Timme Hosting(超高速nginxウェブホスティング)のオーナーです。彼はHowtoForgeのリードメンテイナー(2005年から)であり、ISPConfigのコア開発者の1人(2000年から)でもあります。彼はまた、O’Reillyの書籍「Linux System Administration」にも貢献しています。

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。