Skip to content

Instantly share code, notes, and snippets.

@s1moe2
Last active August 22, 2019 08:29
Show Gist options
  • Save s1moe2/79fcc70cdc147f5ad57587cee7645af9 to your computer and use it in GitHub Desktop.
Save s1moe2/79fcc70cdc147f5ad57587cee7645af9 to your computer and use it in GitHub Desktop.
Local Docker MySQL (5.7) server setup

Local Docker MySQL server setup

  • Pull latest MySQL docker image

docker pull mysql:5.7

  • Create a directory to mount volumes and persist container data

mkdir -p $HOME/docker/volumes/mysql5.7

  • Start the thing

docker run --rm --name mysql5.7-docker -e MYSQL_ROOT_PASSWORD=mypassword -d -p 127.0.0.1:3306:3306 -v $HOME/docker/volumes/mysql5.7:/var/lib/mysql mysql:5.7

  • Connect to the database server

docker exec --tty --interactive mysql5.7-docker mysql -uroot -p

  • Restore a backup

docker exec --interactive mysql5.7-docker mysql -uroot -ppassword database < backup.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment