メモメモメモ

ほんとうにめも

【Laravel】mysqlを8系にアップグレードしたらmigrationができなくなった

エラー

   Illuminate\Database\QueryException  : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = hoge and table_name = migrations)

解決方法

Mysqlユーザの認証方式を変更する。 ※以下、ユーザ名"root"を使ってる場合を想定して書きます。

既存mysqlユーザーの認証方式を確認

SELECT user, host, plugin FROM mysql.user;

既存mysqlユーザーの認証方式を変更

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-password';

原因

mysql8系以降は認証方式が変わったようです。

before: caching_sha2_password after: mysql_native_password

参考

qiita.com