Skip to content

Instantly share code, notes, and snippets.

@ro31337
Created April 30, 2018 03:49
Show Gist options
  • Save ro31337/00e409f036ae251e8ffa8fa9648a79b6 to your computer and use it in GitHub Desktop.
Save ro31337/00e409f036ae251e8ffa8fa9648a79b6 to your computer and use it in GitHub Desktop.
MariaDB (MySQL) through Docker

MariaDB (MySQL).

Docker is the easiest way to have MariaDB running.

Create volume so your storage will be preserved (argument to -v parameter below):

docker volume create mariadb

Run MariaDB container:

CID=$(docker run -d -v mariadb:/var/lib/mysql -p 127.0.0.1:3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true mariadb --collation-server=utf8mb4_unicode_ci --character-set-server=utf8mb4) && IPADDR=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID) && echo "IP/PORT: $IPADDR:3306" && docker exec -ti $CID bash

If successful, you'll be logged into container. Type mysql -uroot to log in into development database (also, container port 3306 should be mapped to localhost).

Troubleshooting

Docker stop and remove all (will also remove all images):

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment