LARAVEL - Error when connecting MYSQL with LARADOCK in Workspace

Asked

Viewed 899 times

-1

When I try to run the command on the laradock’s 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 file configuration .env of laradock

### 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 Larable

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 in phpMyadmin it enters normal:

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

PS: When I’m outside the worskpace of the laradock and change the .env of the project to DB_HOST=127.0.0.1 and turn the remote php artisan migrate it works.

1 answer

0

Problem solved When using on .env laradock MYSQL_VERSION=lasted he used mysql 8.0 and there was a problem. So I switched to 5.7 as follows:

docker-compose down

Change the .env laradock

...
MYSQL_VERSION=5.7
...

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

rm -rf ~/.laradock/data/mysql

Build

docker-compose build mysql

Rise again

docker-compose up -d apache2 mysql phpmyadmin

Solution found here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.