After upgrading MySQL to version 8.0, Any attempt to migrate database throws exception indicating unknown authenticaion method
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2054] The server requested authentication method unknown t
o the client (SQL: select * from information_schema.tables where table_sche
ma = wiki and table_name = migrations)
[PDOException]
SQLSTATE[HY000] [2054] The server requested authentication method unknown t
o the client
[PDOException]
PDO::__construct(): The server requested authentication method unknown to t
he client [caching_sha2_password]
This is due to the fact that MySQL 8.0.4 has changed its default authentication mechanism to caching_sha2_password
. ( second clause )
In order to make it authenticate with your .env
DB_USERNAME
and DB_PASSWORD
follow this instructions:
Add default-authentication-plugin=mysql_native_password
to your my.cnf
On CentOS/RHEL it's located on /etc/my.cnf
.
On Debian/Ubuntu, I do believe it's located on /etc/mysql
.
This will revert back the default authentication mechanism back to username password.
Login to your mysql and follow procedure
Remove existing database user and recreate it.
In order to remove the user:
DROP USER yourUser@localhost;
(with assumption your db is local)
Create another user
CREATE USER user@localhost IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON dbName.* TO user@localhost;
Flush privileges
FLUSH PRIVILEGES;
Logout of mysql and run:
On Centos/RHEL: systemctl restart mysqld
On Debian/Ubuntu: systemctl restart mysql.service
I could get it up and running without database removal.
References:
on windows; terminate sqld from task manager, now from XAMPP control panel stop and restart MySQL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.