LARAVEL - Error connecting MYSQL with LARADOCK in Workspace

0

When I try to run the command in the laradock workspace php artisan migrate the following error occurs:

   Illuminate\Database\QueryException  : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations)

  at /var/www/blog_teste/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")
      /var/www/blog_teste/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

  2   PDO::__construct("mysql:host=mysql;port=3306;dbname=blog", "root", "root", [])
      /var/www/blog_teste/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68

  Please use the argument -v to see more details.

This is the laradock .env file configuration

### MYSQL #################################################

MYSQL_VERSION=latest
MYSQL_DATABASE=default
MYSQL_USER=default
MYSQL_PASSWORD=secret
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=root
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d

This is the .env of laravel

APP_NAME=Laravel

APP_ENV=local
APP_KEY=base64:Mxx0n7ac05Sz1lPasIe2TJZLqPke11oFLj5udxKKpP4=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=root

When I try to connect to phpMyadmin it goes in normal:

url: http://localhost:8080 
servidor: mysql
usuario: root
senha:root

PS: When I am out of the% coop of laradock and change the .env project to worskpace and squeeze the DB_HOST=127.0.0.1 / p>     

asked by anonymous 15.09.2018 / 06:15

1 answer

0

Problem resolved When using .env of laradock MYSQL_VERSION=lasted it used mysql 8.0 and there was problem. So I changed to 5.7 as follows:

docker-compose down

Change the .env of laradock

...
MYSQL_VERSION=5.7
...

Delete the databases: remove all tables from the database !!

rm -rf ~/.laradock/data/mysql

Build

docker-compose build mysql

Upload again

docker-compose up -d apache2 mysql phpmyadmin

Solution found here

    
15.09.2018 / 07:11