Easy access to a dockerized mysql server

Feb 13, 2015

Deploying a new mysql server using Docker is quite easy:

docker run --name mysql mariadb

But once the server is up, you want root access to it from your command-line.
The mariadb repo shows an example
of how to do this. I’ve wrapped their command in a little shell function that
you can add to your .bashrc or .zshrc. If you call the function without
arguments, it will drop you on the mysql prompt. If you give a mysql command as
argument, it will execute it as mysql root and show the result.