I usually keep my files in the location
~/Workspace
. If you prefer to keep it somewhere else please change the commands accordingly.
The links for the installation guides are given along with the prerequisites
$ git clone https://github.com/redmoses/mysql-docker.git ~/Workspace/mysql-docker
Add the following line in your .zshrc
or .bashrc
file depending on the shell you are using
alias mysql='make -C ~/Workspace/mysql-docker/ '
Don't forget to load the alias in your environment. You can do so by using the following command
$ source ~/.zshrc
The first time you start your mysql docker you have to run the following command. This command will download mysql docker image if it's not already there. Then it will start it up according to the docker-compose.yml
configuration.
$ mysql up
Once you've initialized the docker you can open up your terminal and use the following commands accordingly. Please bare in mind the commands will control both MySQL container and phpMyadmin container together.
Start up the mysql container
$ mysql start
Stop the mysql container
$ mysql stop
Restart the mysql container
$ mysql restart
Show the logs of the running container
$ mysql logs
To connect to mysql shell
$ mysql shell
The data will be stored in the location ~/Workspace/mysql-docker/data
To edit your configurations you can open up docker-compose.yml
and change the environment variables accordingly.
MYSQL_ROOT_PASSWORD
The root password of your database serverMYSQL_DATABASE
The name of the default database to start the container with. You can ignore this if you don't want the server to start with an already created database.MYSQL_USER
If you've created a default database then the user defined here will have all permissions over that database.MYSQL_PASSWORD
The default user's password
If you want to have custom mysql settings you can edit the file config/custom.cnf
according to your needs.
You can learn more about this image from here.
If you want to start fresh and delete all old data you can do the following -
$ mysql down && sudo rm -rf ~/Workspace/mysql-docker/data && mysql up
You may access MySql on your local 3306 port and phpMyadmin on your local 8080 port.