Last active
May 20, 2016 16:30
-
-
Save ezarko/6ae06f08fbf9c7632b64bdab114c30c4 to your computer and use it in GitHub Desktop.
Useful bash function for interacting with a mysql database in a mariadb docker container.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mysql <container> [...] | |
function mysql { | |
docker run -it --link $1:mysql --rm mariadb sh -c "exec mysql -h\"\$MYSQL_PORT_3306_TCP_ADDR\" -P\"\$MYSQL_PORT_3306_TCP_PORT\" -uroot -p\"\$MYSQL_ENV_MYSQL_ROOT_PASSWORD\" ${@:2}" | |
} | |
# mysqladmin <container> [...] | |
function mysqladmin { | |
docker run -it --link $1:mysql --rm mariadb sh -c "exec mysqladmin -h\"\$MYSQL_PORT_3306_TCP_ADDR\" -P\"\$MYSQL_PORT_3306_TCP_PORT\" -uroot -p\"\$MYSQL_ENV_MYSQL_ROOT_PASSWORD\" ${@:2}" | |
} | |
# mysqldump <container> [...] | |
function mysqldump { | |
docker run -it --link $1:mysql --rm mariadb sh -c "exec mysqldump -h\"\$MYSQL_PORT_3306_TCP_ADDR\" -P\"\$MYSQL_PORT_3306_TCP_PORT\" -uroot -p\"\$MYSQL_ENV_MYSQL_ROOT_PASSWORD\" ${@:2}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment