Sep 27, 2020
0
Level 8
How to create testing database under docker?
Hello, In Kubuntu 18 I create docker for laravel 6 app with mysql defined :
mysql:
container_name: "vanilla-crm-db"
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: "MYSQL_ROOT_PASSWORD"
MYSQL_DATABASE: "vanilla-crm-dev"
MYSQL_USER: "MYSQL_USER"
MYSQL_PASSWORD: "MYSQL_PASSWORD"
ports:
- "3330:3306"
volumes:
- "./docker/mysql/data:/var/lib/mysql"
and it works for me.
Next I make http tests and I need to create new database for this and load dump of my database in it. Name of this database is writen in config/database.php under 'mysql_testing' block
- I enter the bash with command :
docker-compose exec mysql bash
root@f216ef80c104:/# uname -a
Linux f216ef80c104 4.15.0-118-generic #119-Ubuntu SMP Tue Sep 8 12:30:01 UTC 2020 x86_64 GNU/Linux
Where mysql is container_name in docker-compose.yml
Usually I enter mysql console with command:
mysql -u root -h localhost -p
But which must be format of this command in the docker console? I tried several ways and failed...
- I use DBeaver and logged into my database and tried to create new database for testing. I got error: https://prnt.sc/uol0z7
How to fix it ? Have I to add some more right my mysql container definitions?
Thanks!
Please or to participate in this conversation.