phpMyAdminにログインできない
環境
・macOS Big Sur 11.4
・MySQL 8.0.25
・PHP 7.3
1. phpMyAdminでの初めてのログイン
phpMyAdminにてログインをしたら、「MySQLサーバーにログインできません」、「mysqli::real_connect(): (HY000/2002): No such file or directory」というエラーが表示された。
解決策
【phpMyAdmin】No such file or directory | ミーミルの泥泉
上記のURLの記事の方法を使用させていただき、
share/phpmyadmin/内のconfig.inc.phpファイルの一部分を変更しました。
$cfg['Servers'][$i]['host'] = 'localhost';
↓
$cfg['Servers'][$i]['host'] = '127.0.0.1';
2. phpMyAdminでの2度目のログイン
127.0.0.1に変更してから再度ログインしたら次は、
「mysqli::real_connect(): The server requested authentication unknown to the client [chasing_sha2_password]」
「mysqli::real_connect(): (HY000/2054): The server requested authentication method unknown to the client」というエラーが表示されました。
解決策
my.cnfに「default_authentication_plugin=mysql_native_password」を追記し、MySQLを再起動したところ、無事にログインできました。
※追記する場所は、どこでも良いみたいです。
追記
MySQLの設定ファイルmy.cnfを探す方法
「mysql --help | grep my.cnf」をターミナルに入力します。
入力すると「ordere of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf」と
ファイルがある場所を表示してくれました。
参考文献