LoginSignup
0
0

PHPMyAdminにログインできない場合の対処法

Posted at

いつも通りXAMPPを使用してPHPMyAdminを使用としたら、以下のように表示された。
解決するのに少し時間がかかったのでメモ書き。
image.png

どこが原因か探る

・MySQLはログインできるか確認する。
<確認方法>
①XAMPPのコントロールパネルでShellを開く。
image.png
②Shellに以下のコマンドを入力する。

mysql -u root -p

③パスワードを聞かれたら、パスワードを入力してEnterを押す。
④ログインできない場合は以下を試す。

・MySQLにパスワードありでログインできなかった場合
①XAMPPのコントロールパネルで、 MySQL > Config > my.ini を開く。
image.png
[mysqld]の下に以下を入力する。
 以下を入力することでパスワードなしでMySQLにログインが可能になる。

skip-grant-tables

image.png
③Shellに以下のコマンドを入力する。

mysql -u root

④ログイン出来たら、Shellに以下を入力する。
 use mysqlを指定することで、パスワードなどが登録されたデータベースを使用する。

use mysql
flush privileges;

⑤同じくShellに以下を入力する。
 new_passwordに任意のパスワードを入力する。

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

⑥MySQLのmy.iniに入力したskip-grant-tables を削除し、
 XAMPPのMySQLを再起動する。
⑦Shellを起動し、以下を入力してログイン出来たらOK。

mysql -u root -p

PHPMyAdminのパスワードを変更する。

①C:\xampp\phpMyAdmin\config.inc.php の以下に設定したパスワードを入力する。

config.inc.php
$cfg['Servers'][$i]['password'] = '任意のパスワード';
$cfg['Servers'][$i]['controlpass'] = '任意のパスワード';

②PHPMyAdminにログインする。ログイン出来ればOK。

参考サイト

MySQLでパスワードを忘れた場合の対処法
https://blog.senseshare.jp/forget-rootpassword.html

phpMyAdminにログインできなくなった時の解決方法
https://masafumi-blog.com/what-to-do-if-you-cant-log-in-to-phpmyadmin

0
0
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
0
0