LoginSignup
17
16

More than 5 years have passed since last update.

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

Last updated at Posted at 2018-06-22

事象

MacでMysqlを5.6から8.0にupgradeした後、LaravelからMysqlにアクセスできなくなった。

ちなみにupgradeのコマンドは、

$ brew upgrade mysql
$ mysql_upgrade

エラー内容

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

解決方法

my.cnfの設定を変更する

まず、my.cnfの場所を特定する

$ mysql --help | grep my.cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

左から順に存在するファイルを確認していく

$ ll /etc/my.cnf
ls: /etc/my.cnf: No such file or directory
$ ll /etc/mysql/my.cnf
ls: /etc/my.cnf: No such file or directory
$ ll /usr/local/etc/my.cnf
-rw-r--r--  1 hogehoge  admin   167B  6 22 11:46 /usr/local/etc/my.cnf

/usr/local/etc/my.cnfが存在しているので、これの末尾に、
default_authentication_plugin= mysql_native_password
を加える

例)

# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
default_authentication_plugin= mysql_native_password

mysqlを再起動する

$ sudo mysql.server restart

これで完了

Tips

Sequel Proで接続できない場合は、Pre-release版からなら行けるはず
https://github.com/sequelpro/sequelpro/releases

17
16
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
17
16