R
R
Romi2021-03-27 22:20:39
Docker
Romi, 2021-03-27 22:20:39

Laradock (Docker) - Can't run migrations - SQLSTATE[HY000] [2002] Connection refused - what to do?

Installed Laradock (Docker Compose configured for Laravel).

I go into the box:

docker-compose exec workspace bash

I go to the folder with Laravel, run migrations, I get this:

[email protected]:/var/www/project1# php artisan migrate

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = default and table_name = migrations and table_type = 'BASE TABLE')


.env 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


.env Laravel

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret


** at the same time, in PhpMyAdmin - with these data (default:secret) logs in normally. True, what a STRANGE user - without privileges to create databases, etc.

How can this be solved radically so that there are no dances with a tambourine?

What am I doing wrong?

Thank you.

PS Like this:

docker-compose exec mysql mysql -u root -proot

it also logs in normally and immediately enters the MySQL command line. when I googled it - I found it) though it's not clear what to do with it))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
N, 2021-03-27
@romicohen

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret

Do like this:
DB_HOST=mysql
PS:
Do not forget to do after each config change:
php artisan config:cache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question