Difference between revisions of "Docker install of mysql"

From MyWiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
docker run --name mysql-8 -e MYSQL_ROOT_PASSWORD=<password> -d mysql:8.0.33
 
docker run --name mysql-8 -e MYSQL_ROOT_PASSWORD=<password> -d mysql:8.0.33
 
docker inspect mysql-8
 
docker inspect mysql-8
# Note, below the "mysql" directory must be created before running the command
+
</source>
 +
Note, below the "mysql" directory must be created before running the command
 +
<source lang="bash">
 
docker run  --name devtest -e MYSQL_ROOT_PASSWORD=<password> -d --mount type=bind,source="$(pwd)"/mysql,target=/var/lib/mysql mysql:latest
 
docker run  --name devtest -e MYSQL_ROOT_PASSWORD=<password> -d --mount type=bind,source="$(pwd)"/mysql,target=/var/lib/mysql mysql:latest
 
+
</source>
 
+
With the following syntax the "mysql" directory gets created automatically
 
+
<source lang="bash">
 +
docker run  --name devtest -e MYSQL_ROOT_PASSWORD=<password> -d -v "$(pwd)"/mysql:/var/lib/mysql mysql:latest
 
</source>
 
</source>

Latest revision as of 19:09, 31 July 2023

Reference: https://hub.docker.com/_/mysql

docker run --name mysql-8 -e MYSQL_ROOT_PASSWORD=<password> -d mysql:8.0.33
docker inspect mysql-8

Note, below the "mysql" directory must be created before running the command

docker run  --name devtest -e MYSQL_ROOT_PASSWORD=<password> -d --mount type=bind,source="$(pwd)"/mysql,target=/var/lib/mysql mysql:latest

With the following syntax the "mysql" directory gets created automatically

docker run  --name devtest -e MYSQL_ROOT_PASSWORD=<password> -d -v "$(pwd)"/mysql:/var/lib/mysql mysql:latest