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


  • Docker version ($ docker --version): Docker version 17.12.0-ce, build c97c6d6
  • Laradock commit ($ git rev-parse HEAD): 8323c659ed588ad2d2b02a13dfab651c051302e8
  • System info (Mac, PC, Linux): MacOS Sierra 10.12.6
  • System info disto/version:


Using the mysql and nginx containers, running a migration yields the following error: The server requested authentication method unknown to the client [caching_sha2_password].

This seems to be due to mysql 8.x forcing a new password format. Attempting to force old_passwords=1 from inside the mysql container yields ERROR 1231 (42000): Variable 'old_passwords' can't be set to the value of '1'.

This does occur when trying to run a migration from inside the workspace - where both the version of php and mysql should be controlled by Laradock.

Expected behavior:

Laravel should be able to login to the database and do its thing.


Pull clean copy of Laradock, set DB_HOST= in .env (for reasons unknown to me, DB_HOST=mysql yields SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known), start the mysql and nginx containers, enter the workspace container and run php artisan migrate.

45 Answers

✔️Accepted Answer

+1, I'm having the same problem here.

Other Answers:

Me too, same problem .

i did resolved the problem following:

  1. add default authentication plugin to laradock/mysql/my.cnf
default_authentication_plugin= mysql_native_password
  1. update content file mysql/docker-entrypoint-initdb.d/createdb.sql like:
CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpass';
CREATE USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpass';
CREATE DATABASE IF NOT EXISTS `yourdb` COLLATE 'utf8_general_ci' ;
GRANT ALL ON `yourdb`.* TO 'admin'@'%' ;

important note: remove old user, database and recreate again by above script.
3. Remove mysql container and re-run it.
4. php artisan migrate is done :)

Reason bug:
Default authenticate of MySQL 8.0.4 changed.
Refer to detail information:
at Security Notes

hope it help you.

Thanks @rockerbom for the thorough response. I didn't try your steps, but ended up with a different solution (for anyone that doesn't necessarily need MySQL 8.x):

  1. Changed MYSQL_VERSION to 5.7 in laradock/.env
  2. docker-compose build --no-cache mysql

@robindijkhof Use this to solve problem :

**stop all service docker-compose down
Edit .env file set MYSQL_VERSION=5.7 or MYSQL_VERSION=latest

Delete mysql database

$ rm -rf ~/.laradock/data/mysql

rebuild mysql image

$ docker-compose build mysql


$ docker-compose up -d nginx mysql phpmyadmin
It's working for me.**

Have a stable solution after a few days banging thy head. MySQL 8.0 is not stable at all for me. I am surprised it is a part of Laradock. Does anyone know why a dev version is included VS a production version? Once I downgraded to 5.7 all errors above are gone and my head is healing. Like to suggest to the developers of Laradock to please use a stable version of MySQL so others may not need to travel the road of misery.

Related Issues:

laradock Mysql. The server requested authentication method unknown to the client [caching_sha2_password]
alter user 'username'@'localhost' identified with mysql_native_password by 'password'; would fix it....
laradock SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
+1 I'm having the same problem here. Info: Docker version ($ docker --version): Docker version 17.12...
laradock MySQL Container fails to start
I had the same issue last night I think it's the mysql version problem What I did was edited laradoc...
laradock ERROR: 404 page not found
I had this problem because the root path in docker-compose.yml differs from the one in nginx default...
laradock When Using docker-compose up mysql MySQL Doesn't Start
I solved this problem This is because of data folder I was running it using mysql 5.7 then abort it ...
laradock Guzzle/Curl connections between multiple projects
That's literary the only change you need to do not going to post the whole of docker-compose file in...
laradock Fails to initialize MySQL database
edit .env DATA_SAVE_PATH=~/.laradock/data to DATA_SAVE_PATH=./data Absolute directory d:\docker_www\...
laradock Laradock mysql exited with code 2
'/tmp' dir not exists on windows please help ...
laradock Unable to start up MySQL container
Do you have any important databases in your machine? If you have no dbs there I think you should rem...
laradock SQLSTATE[HY000] [2002] Connection refused
@asolopovas change your db host to mysql DB_CONNECTION=mysql DB_HOST=mysql Hi I am running laradock ...
laradock How to add SSL to NGINX in laradock.
Within your site config file you will want something similar to the below You will then want to add ...
laradock Routing issue with Laravel and Guzzle
could you try changing to your web server container name whether it's nginx or apache2 lik...
laradock No way to authorize private channels in laravel-echo-server
I solve this problem by adding an alias to nginx service in docker-compose.yml reference: aliases in...
laradock Laradock with both php 5.6 and 7.0
I needed php-fpm 7.0 and 5.6 Hello ...
laradock How can I connect to mysql from outside? Like Workbrench
@pablorsk You can forward the MySQL port to your host by adding the lines To the mysql section of th...
laradock Mariadb plugin 'InnoDB' init function returned error.
The only way I found round this was to backup my /var/lib/mysql and /var/lib/mariadb directories by ...
laradock Too many errors
@lisabonde Please copy the env-example file to .env Within the .env file you can then set your prefe...
laradock Can't install Node & npm
The .env file also has a WORKSPACE_INSTALL_PYTHON which is set to false by default If you set it to ...
laradock How to connect database with my own project with laradock?
@at-tienpham check all container state is up try login PHPMyAdmin: Open Browser http://localhost:88 ...
laradock Multiple sites (Run many laravel projects)
I forked this for work and have an implementation of this working What I did is merge application an...
laradock Docker on Mac is slow
Found the solution: IFSight/d4m-nfs#5 In order to be able to use d4m-nfs you just need to perform th...
laradock xDebug PhpStorm Working Via CLI - Not Working Via Web Page/Apache
@fideloper all you need is xdebug.remote_connect_back = Off Here is a quote from xdebug documentatio...
laradock No releases available for package ""
Doing pecl channel-update as suggested by @ivanferrer solved the problem for me ...
laradock Secure Nginx with Let's Encrypt Guide
Just yesterday i solved this problem for me with nginx Problem Definition There doesn't seem to be a...
laradock Two databases in one MySQL container
If you are struggling with having a non-root user for all databases on container init integrating wh...
laradock Docker-sync integration does not work this way - it has no effect right now
@godbout I was able to get it working on Windows Due to
laradock Cannot build php-fpm
Ok I've just got it working although I'm still not sure on the exact cause When try run docker-compo...
laradock Add Crontab and Supervisor
For the queue part I've simply added a service to the stack: add crontab and supervisor support if w...
laradock Elixir/Mix with Browsersync
@cjmaxik Great! Try using the hostnames nginx and caddy. So I finally managed to have Browsersync wo...
laradock MSSQL Initialise Problem
Hi @Nelsoft-EphraimLambarte it happened a couple of months ago not sure if it´s fixed now but I'm no...
nvidia docker OpenCV Docker error "ImportError: cannot open shared object file: No such file or directory"
I fixed this problem on with (using solution above): ...
compose Docker-compose up failing because "port is already allocated"
I ran into the same issue today (with a postgres container) and despite having tried docker-compose ...
moby The name "/data-container-name" is already used by container <hash>. You have to remove (or rename) that container to be able to reuse that name.
I have a helper function to nuke everything so that our Continuous blah cycle can be tested erm.. co...
compose Compose error "HTTP request took too long to complete"
By simply restarting the docker service via sudo service docker restart I was able to get the aforem...
compose error on launching docker-compose by piping to sh ( echo 'docker-compose ... ' | sh )
I could get it to work by adding the -T parameter to not create a Pseudo-TTY docker-compose exec -T ...
compose docker-compose up fails if network attached to container is removed
Thanks for the report! I think there are several things to note here: First and foremost ...
nvidia docker docker: Error response from daemon: Unknown runtime specified nvidia.
I've also installed correctly but forgot to restart daemon in ubuntu it may resolve your error. ...
compose Error when trying to run docker-compose up. "oci runtime error: container_linux.go:247..."
you gotta make the an executable before building the image: otherwise it cant b...
compose docker-compose up doesn't pull down latest image if the image exists locally
Imagine that git didn't have pull because git fetch && git merge origin/master is functionally ident...
nvidia docker could not select device driver "" with capabilities: [[gpu]].
Hello! If you didn't already make sure you've installed the nvidia-container-toolkit If this doesn't...
moby docker-engine 1.10.2-0~trusty can't install on clean Ubuntu 64-bit 14.04.3
I seem to have resolved this by putting deb trusty main in /etc/...
moby Docker service update --image "could not accessed on a registry to record its digest"
When updating services that need credentials to pull the image you need to pass --with-registry-auth...
compose Docker Compose mounts named volumes as 'root' exclusively
Actually I come here with news it seems what I am trying to achieve is doable but I don't know if th...
compose INTERNAL ERROR: cannot create temporary directory!
Confirming this happened to me Today Was running low on space: After removing a container.. it works...
cookiecutter django No support for python3? I am getting: invalid syntax: raise ValueError, "No frame marked with %s." % fname
For me the issue was that I installed the environ package instead of the django-environ package. ...
compose docker-compose up -d doesn't expose ports when defined with build directive
oh you didn't specify but I'm assuming you're using run instead of up? If so you need --service-port...
compose How does compose chooses subnet for default network?
I'm also running into this issue Another way around this is to set the default-address-pools in your...
ddev In WSL2 ddev start fails at docker-credential-desktop.exe, "error listing credentials"
I had to set credsStore: in my ~/.docker/config.json .. it was previously set to credentials.exe ...