简体   繁体   中英

laradock error on phpmyadmin - can't connect

I just started using docker, laradock and laravel, after setting up the entire environment I tried to login on my phpmyadmin and I couldn't sign in.

I looked pretty much everywhere and couldn't find a way to fix it so you guys are my last hope lol.

Docker version 17.12.0-ce, build c97c6d6 Here's my docker ps
码头工人

My project's .env

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

And here are the errors I am getting from phpmyadmin (localhost:8080)

#2054 - The server requested authentication method unknown to the client
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client

The easiest solution is to revert back to an earlier version of MySQL. It's probably a good idea anyway since 8.0 is a "developer's release". Unfortunately Laradock currently has a bug that installs 8.0 no matter what you set in the .env file. I've submitted a PR on Laradock to fix this particular issue.

https://github.com/laradock/laradock/pull/1409

This is caused by an update to libmysqlclient since MySQL version 8.0.4 which has changed the default authentication method to a more secure sha256_password .

As soon as Laravel and other software packages such as PhpMyAdmin are updated to support this new and more secure authentication method this problem wil resolve itself.

If you CANNOT delete and rebuild your existing mysql data volume, simply:

  1. Sign in to your mysql container ( docker-compose exec mysql mysql -uroot -proot )
  2. Execute ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
  3. Repeat step 2 for any other users you may have created.

If you CAN recreate your mysql data volume:

  1. Modify your my.conf file. Under [mysqld] add the following configuration option default_authentication_plugin=mysql_native_password
  2. Delete your mysql volume rm -rf ~./laradock/data/mysql
  3. Rebuild the mysql container docker-compose -d --build mysql phpmyadmin

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM