1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【phpMyadmin】phpMyAdmin環境保管領域が完全に設定されていない・#1142 - SELECT command denied to userのエラー対応

Posted at

概要

  • EC2にインストールしたWordpressのphpMyadminにアクセスできるようになり、中身を触っていたら、以下の警告が表示されていましたので、この警告を解決した手順を残します。
『phpMyAdmin環境保管領域が完全に設定されていないため、いくつかの拡張機能が無効になっています。』

スクリーンショット 2023-03-17 0.21.39.png

環境

  • Mac
    • 機種ID:MacBookPro18,3
    • macOS:Monterey
    • チップ:Apple M1 Pro
    • メモリ:16GB
  • サーバー(AWS EC2インスタンス)
    • OS:Ubuntu 18.04.3 LTS
    • Web Server:Apache/2.4.29

解決手順

  • 手順は、以下の記事を参考にしました。
  • まずは、管理者権限(root)ユーザーでphpmyadminにログインします。
  • 「理由についてはこちらをご覧下さい。」の『こちら』をクリックします。
  • 『「phpmyadmin」データベースを作成し、phpMyAdmin 環境保管領域をセットアップ。』の『作成』をクリックします。
    *左ペインをみると phpmyadminデータベースが作成されたことがわかります。
  • 次に、以下コマンドでconfig.inc.php編集します。
    • config.inc.phpは、phpMyAdminを構成するための設定ファイルです。phpMyAdminの外観や動作をカスタマイズしたり、不正アクセスや攻撃からphpMyAdminを保護したりもしています。
$ cd /etc/phpmyadmin
$ sudo vi config.inc.php
  • Storage database and tablesのコメントアウトしている各20行の先頭の「//」を削除します。
    • 削除すると以下のようになります。
/* 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';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
  • 削除ができたら保存します。
  • phpmyAdminに再度ログインすると先ほどの警告エラーが消えたことがわかります。
  • ただし、その後にエラー対応があったので、それを記します。

エラー対応:#1142 - SELECT command denied to user...

  • データベースのテーブルを選択すると、以下のエラーがポップアップで出ました。
エラー
SQL query: ドキュメント編集 編集


SELECT tracking_active FROM `phpmyadmin`.`pma__tracking` WHERE db_name = 'sample-db'  AND table_name = 'wp_commentmeta'  ORDER BY version DESC
MySQL のメッセージ: ドキュメント

#1142 - SELECT command denied to user 'sample-user'@'xxx.xx.x.x' for table 'pma__tracking'
  • ユーザーが「pma__tracking」テーブルに対してSELECTコマンドを実行する権限がないらしい。
  • ということで、管理者ユーザー(rootユーザー)でphpmyadminにログインします。
  • DBのphpmyadminのテーブルpma__trackingを選択して「特権」タブをクリックします。
  • sample-userをEdit privilegesで編集し、権限を追加します。

image.png

  • CheckAllで全権限付与してもいいですし、SELECTのみにしても良いですが、ここはそれぞれのルールに従ってください。最低、SELECTは選ばないと、テーブルを押すだけでまたエラーが出てしまいます。今回のユーザーは強い権限を持ってもらうものだったので、自分の場合は全てチェック。

image.png

  • 「実行」をクリックします。
  • phpmyadminに再度ログインすると、先ほどのエラーポップアップが表示されることなくデータベースのテーブルを選択できるようになりました。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?