mysql docker on mac os "crash" on caching_sha2 when laravel connect

Kamil Kiełczewski

I made factory-reset on my Mac Mini, and I wanna install only Docker and some basic tools like git directly on OS X but other for software I wanna use docker - by other soft I mean app like php, phpstorm, nginx, node, mysql, postgres, phpmyadmin, mysql-workbench... in many versions. I wanna install them using docker to easily manage them. For each of this tool I wana to map folder with e.g. code of my projects or db storagem, configuration etc...

During setup mysql 8 I face strange problem - I was able to login as root to db by phpmyadmin and mysql-workbench but my php 7 laravel appliaction "hangs" during connection. Here is mysql dockerfile:

version: '3.1'

services:

  db:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: terefere321
      MYSQL_ROOT_HOST: "%"
    ports:
      - 3306:3306
    volumes:
    - ./db_files:/var/lib/mysql

Here is docker file + script which allow me to run php via cmd on docker:

FROM php:7.2-apache

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apt-get update &&\
    apt-get install -y \
    git \
    zlib1g-dev \
    zip \
    unzip \
    &&\ 
    docker-php-ext-install pdo pdo_mysql zip &&\
    a2enmod rewrite 

Bash script to run php-cmd docker container and "login" to it to get command line:

set -e
cd -- "$(dirname "$0")"  # go to script dir - (for macos double clik run)
docker build -t php-cmd .
docker rm -f php-cmd
docker run -d --name php-cmd -v /Volumes/work:/var/www/html php-cmd
docker exec -it php-cmd /bin/bash

Here /Volumes/work is directory with code of my project. After "login" i run php artisan migrate and app hangs for 30s and after throw errors:

SQLSTATE[HY000] [2006] MySQL server has gone away PDO::__construct():

Unexpected server respose while doing caching_sha2 auth : 109

Kamil Kiełczewski

Add default-authentication-plugin=mysql_native_password command to mysql8 dockerfile - so you should get:

version: '3.1'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: terefere321
      MYSQL_ROOT_HOST: "%"
    ports:
      - 3306:3306
    volumes:
    - ./db_files:/var/lib/mysql

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Can not connect mysql with laravel (docker)

How to connect to MySQL in c++ on mac os?

How to connect Sequel Pro (on a Mac) to a MySQL in a Docker

How to connect Laravel to MAMP mysql on Mac

Dreamweaver (Mac) crash on connect SFTP

Connect to mySQL in Laravel 9 installed using Docker

How to connect to Docker DB (Laravel with ddev and MySQL)

Couldn't connect to Docker daemon on Mac OS X

Connect to a remote Database that live in Docker via Mac OS X

Mysql crash when querying

Cannot connect to MySQL (python MySql-Connector) when in docker container

Empty response when running REST application on docker with Mac OS

Docker invalid reference when using $(pwd) mac os

Crash in QMetaObject::changeGuard on Mac OS 10.9

boot2docker, docker, django on mac os x

RMariaDB: caching_sha2_password error when connecting to MySQL

How to connect R to MySQL? Failed to connect to database: Error: Plugin caching_sha2_password could not be loaded

Cant connect apache mysql when using docker swarm

Cannot connect to mysql on docker

connect to mysql server in docker

How to not crash when a socket fails to connect

How to connect to mysql with laravel?

Setup discourse docker on mac os

In Mac OS X, how to automatically connect to samba server when machine starts?

MySQL 8.0.11 error connect to caching_sha2_password the specified module could not be found

Cannot connect to mysql : Unable to load authentication plugin 'caching_sha2_password

Why does my .NET web API application not connect to MySQL on docker when using docker-compose?

Restart Docker Containers when they Crash Automatically

crash error when execute docker-compose

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  7. 7

    Do Idle Snowflake Connections Use Cloud Services Credits?

  8. 8

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  9. 9

    Binding element 'string' implicitly has an 'any' type

  10. 10

    BigQuery - concatenate ignoring NULL

  11. 11

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  12. 12

    In Skype, how to block "User requests your details"?

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Pandas - check if dataframe has negative value in any column

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Generate random UUIDv4 with Elm

  17. 17

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  18. 18

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  19. 19

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  20. 20

    EXCEL: Find sum of values in one column with criteria from other column

  21. 21

    How to use merge windows unallocated space into Ubuntu using GParted?

HotTag

Archive