- Pull and start a MySQL install
1 2 3
| docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
|
some-mysql
is the name you want to assign to your container.
my-secret-pw
is the password to be set for the MySQL root user.
tag
is the tag specifying the MySQL version you want.
-p host_port:container_port
.
Now can also use client to connect the data base via port 3306
- Import local (host)
.sql
file to the container
1
| docker cp /opt/a.sql my-mysql:/tmp/
|
- Log in to Docker MySQL
1
| docker exec -it my-mysql mysql -uroot -p000000
|
Should see mysql>
- Create database
1
| CREATE DATABASE my_database;
|
- Select database
- Execute sql file