アーカイブ

2014 年 12 月 16 日 のアーカイブ

phpmyadminを最新バージョンにアップデート その2

2014 年 12 月 16 日 Comments off

MYSQLを5.1から5.5にバージョンアップしてやっとphpmyadminでもログインすることができました。

しかし、ログインするもなにやら注意メッセージが

こちらのサイトを参考にさせていただきました。

phpmyadmin6

「 環境設定は、現在のセッションでのみ有効です。この設定を永続的に有効にするには、phpMyAdmin 環境保管領域が必要です。」 とのこと

phpmyadminのリンク先をたどると英語ですがなんとなくですが

examplesというフォルダにあるcreate_tables.sqlをインポートせよ見たいに書いてある

and then create new tables by importing examples/create_tables.sql.

まず実際にものがあるか確認

[root@www16071ue examples]# ls -la /var/www/phpmyadmin/examples
合計 64
drwxr-xr-x 2 root apache 4096 12月  9 02:34 2014 .
drwxr-xr-x 9 root apache 4096 12月 10 13:36 2014 ..
-rw-r--r-- 1 root apache 2011 12月  9 02:34 2014 config.manyhosts.inc.php
-rw-r--r-- 1 root apache 9943 12月  9 02:34 2014 create_tables.sql
-rw-r--r-- 1 root apache 7893 12月  9 02:34 2014 create_tables_drizzle.sql
-rw-r--r-- 1 root apache 4510 12月  9 02:34 2014 openid.php
-rw-r--r-- 1 root apache  805 12月  9 02:34 2014 signon-script.php
-rw-r--r-- 1 root apache 2430 12月  9 02:34 2014 signon.php
-rw-r--r-- 1 root apache 1557 12月  9 02:34 2014 swekey.sample.conf
-rw-r--r-- 1 root apache 1665 12月  9 02:34 2014 upgrade_column_info_4_3_0+.sql
-rw-r--r-- 1 root apache 5691 12月  9 02:34 2014 upgrade_tables_mysql_4_1_2+.sql

それっぽいsqlファイルが3つあります。
どのSQLを走らせればよいか英文からは、よくわからないのでSQLを直接見てみます。
その前にHPの文では、
upgraded to phpMyAdmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x) 翻訳–>2.5.0以降からphpMyAdminの4.3.0以降にアップグレードした(<=4.2.xでは)

upgrade_column_info_4_3_0+.sql

-- -------------------------------------------------------------
-- SQL Commands to upgrade pmadb.pma__column_info table
-- for normal phpMyAdmin operation
--
-- This file is meant for use with phpMyAdmin 4.3.0 and above!
-- For older releases, please use create_tables.sql
--
-- Please don't forget to set up the table names in config.inc.php
--

-- --------------------------------------------------------

--
-- Database : `phpmyadmin`
--
USE `phpmyadmin`;

-- --------------------------------------------------------

--
-- Update table structure for table `pma__column_info`
--
UPDATE `pma__column_info`
  SET `mimetype` = REPLACE(`mimetype`, 'octet-stream', 'octetstream');
UPDATE `pma__column_info`

データベース名phpmyadminにphpmyadminユーザでログインしてpma__column_infoテーブルに対してアップデート(更新)コマンドやALTER(変更)コマンドを実行しているようです。

しかし、phpmyadminでログインしてみるとご覧のとおりデータベース名phpmyadminは、ありません。
cats-crop

ということでもし、phpmyadminというデータベース名がある場合は、こちらのSQLでいいと思いますが当サーバでは、違うようです。
— This file is meant for use with phpMyAdmin 4.3.0 and above!
— For older releases, please use create_tables.sqlと書いてあり古いリリースの場合、create_table.sqlを使用してくださいと書いてある。

ということでこのcreate_table.sqlを確認してみる。

-- SQL Commands to set up the pmadb as described in the documentation.
--
-- This file is meant for use with MySQL 5 and above!
--
-- This script expects the user pma to already be existing. If we would put a
-- line here to create him too many users might just use this script and end
-- up with having the same password for the controluser.
--
-- This user "pma" must be defined in config.inc.php (controluser/controlpass)
--
-- Please don't forget to set up the tablenames in config.inc.php
--

-- --------------------------------------------------------

--
-- Database : `phpmyadmin`
--
CREATE DATABASE IF NOT EXISTS `phpmyadmin`
  DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE phpmyadmin;

-- --------------------------------------------------------

--
-- Privileges
--
-- (activate this statement if necessary)
-- GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON `phpmyadmin`.* TO
--    'pma'@localhost;

~省略~

-- --------------------------------------------------------

当然ファイル名のとおりデータベースphpmyadminとユーザをcreateしてくれているようです。
このデータベースに色々なテーブルをcreateしているようですのでこのSQLで間違いないようです。

では、実際にSQL文を実行して見ます。

[root@local examples]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7646
Server version: 5.5.41 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2014, 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> source /var/www/phpmyadmin/examples/create_tables.sql
Query OK, 1 row affected (0.03 sec)

Database changed
Query OK, 0 rows affected (0.87 sec)
Query OK, 0 rows affected (0.18 sec)
Query OK, 0 rows affected (0.17 sec)
Query OK, 0 rows affected (0.16 sec)
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.40 sec)
Query OK, 0 rows affected (0.07 sec)
Query OK, 0 rows affected (0.11 sec)
Query OK, 0 rows affected (0.05 sec)
Query OK, 0 rows affected (0.04 sec)
Query OK, 0 rows affected (0.16 sec)
Query OK, 0 rows affected (0.17 sec)
Query OK, 0 rows affected (0.13 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.23 sec)
Query OK, 0 rows affected (0.05 sec)
Query OK, 0 rows affected (0.28 sec)

17行Query OKが出れば成功

 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

phpmyadminが作成されてます。
次にconfig.inc.phpのテーブル設定を変更します。
pmaユーザを別に作成・使用する場合は、/* User used to manipulate with storage */も行頭の//をはずします。
今回は、ユーザを作らないので下記のStorage database and tablesの項目すべて行頭の//をはずします。
データベース名1行+テーブル17行の計18行
この行数は、createテーブルしたときのQuery OKの行とリンクしていると思われるのでphpmyadminのバージョンによっては、違うかも

/* Storage database and tables */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $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]['table_uiprefs'] = 'pma__table_uiprefs';
// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
// $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
/* Contrib / Swekey authentication */

変更後

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$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]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
/* Contrib / Swekey authentication */

phpMyAdminからログアウトして、再度ログインすると下記のように注意メッセージも消えてます。

phpmyadmin設定画面

これでphpmyadminもきれいにバージョンアップしました。

カテゴリー: Linux, mysql, php タグ: , ,