Answer the question
In order to leave comments, you need to log in
Where is my db that I deployed in docker-compose actually?
I decided to raise MySQL in the docker, I decided that it was a matter of a couple of minutes.
There is such docker-compose:
version: '3.3'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: 'db'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'user'
# You can use whatever password you like
MYSQL_PASSWORD: 'password'
# Password for root access
MYSQL_ROOT_PASSWORD: 'password'
ports:
# <Port exposed> : < MySQL Port running inside container>
- '3306:3306'
expose:
# Opens port 3306 on the container
- '3306'
# Where our data will be persisted
volumes:
- my-db:/var/lib/mysql
# Names our volume
volumes:
my-db:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
Answer the question
In order to leave comments, you need to log in
In the terminal, from the folder with the project, execute docker-compose exec db bash
This will take you to the container with the database.
Then execute mysql -uroot -p
This will take you to mysql.
Then execute SHOW DATABASES;
So you will see the list of bases in your mysql.
Then execute USE имя_нужной_тебе_базы;
So you will choose the base.
Then execute SHOW TABLES;
So you will see a list of tables that are in the database you selected.
This will help you understand that Lara really connected to mysql in docker.
Further, if you want to delete the database and create again.
Run DROP DATABASE имя_нужной_тебе_базы;
This will delete the database and all the data in it, it will be impossible to restore them, google this command and make sure that you understand exactly what you are doing.
Then run CREATE DATABASE имя_базы_которую_ты_удалил;
This will create a new empty base.
Now you can run the migrations.
The base of this container should have been saved in volume: /var/lib/docker/volumes/my-db/_data
docker volume ls
By default, volumes are stored in
/var/lib/docker/volumes/
The port is open on the wrong interface, the fastest way is to hang it on the localhost like this:
ports:
- "127.0.0.1:3306:3306"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question