LoginSignup
2
0

More than 1 year has passed since last update.

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = hogehoge and table_name = migrations and table_type = 'BASE TABLE')

Posted at

前提

・Mac m1チップ
・Laravel8系
・MySQL8系
・PHP7系
・envファイルに正しくDB情報を書いた。 ← ここまでちゃんと切り分けしましたか?

補足:.envに正しく書いたらしいことを確認する方法

・ターミナルで下記を打って、パスワードをちゃんと入力して入れますか?

 mysql -u 書いたユーザー名 -p 
 show databases;

・下記コマンドを打って、対象DBをちゃんと用意したことを確認しましたか?

show databases;

 → 結果に対象のDB名が出て来れば良い。

・接続先がDockerのMySQLコンテナである場合、別途調べてください。

注意

・タイトルのhogehogeを接続先となるDB名に置き換えて、もし手元のエラーと等しくないならやらない方が良いかもしれません。DBなので。(とは言っても、やってしまっても大丈夫なよう新規ユーザーを作成するような形にしてます。)

解決方法

・利用しているユーザーのパスワードを「mysql_native_password」で変更してやる。

・自分としては、新しくユーザーを作成してから試してみることをお勧めします。

// ユーザー作成
create user fuga@localhost identified by 'fugafuga';

// 権限付与(とりあえず全て。ここは必要に応じてドキュメント読みながら調整。)
grant all privileges on *.* to fuga@localhost;
flush privileges;

// パスワードをmysql_native_passwordを利用して変更する
alter user fuga@localhost identified with mysql_native_password 'fugafuga';

解決するまでに読んだ記事

https://trialanderror.jp/mysql-8x-laravel-migrate/
https://blog.janjan.net/2018/11/01/mysql8-request-authentication-method-unknown-to-the-client/
https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql-ja
https://www.dbonline.jp/mysql/user/index6.html

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