Last active
May 16, 2018 19:20
-
-
Save chrismullins/3f932b928e00b9d2174b535af978e9b0 to your computer and use it in GitHub Desktop.
Setup docker mysql db
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
auth | |
contenttypes | |
sessions | |
messages | |
staticfiles | |
webapp | |
custom_user | |
xlsxwriter | |
business_calendar | |
emails | |
geopy | |
closeio_api | |
requests2 | |
idna | |
urllib3 | |
chardet | |
certifi | |
password_reset | |
refreshbooks | |
driverapp | |
pdfrw | |
reportlab | |
tickets | |
testruns | |
sendgrid | |
python_http_client | |
cwjleadsapp | |
widget_tweaks |
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
Good links: | |
- https://dev.mysql.com/doc/mysql-installation-excerpt/5.5/en/docker-mysql-getting-started.html | |
1. Pull the image: | |
docker pull mysql/mysql-server:latest | |
(if you wanna use another version, just replace latest with the tag you want) | |
2. Build and run the image: | |
docker run -p 3306:3306 --name database1 -e MYSQL_ROOT_PASSWORD=password -d mysql:latest --default-authentication-plugin=mysql_native_password | |
- this last option is because 'caching_sha2_password' is the default auth plugin used in mysql | |
3. Create the database you want: | |
docker exec -it database1 mysql -uroot -p | |
(now you should be in mysql) | |
mysql> CREATE DATABASE database1; | |
(note that we named the docker image database1 as well. There's no reason for this.) | |
4. Kill all the migrations: | |
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete | |
find . -path "*/migrations/*.pyc" -delete | |
5. Make all migrations: | |
for i in `cat ../apps.txt` | |
do | |
python manage.py makemigrations $i | |
done | |
Wanna reset the whole thing? | |
docker kill database1 && docker rm database1 && docker run -p 3306:3306 --name database1 -e MYSQL_ROOT_PASSWORD=password -d mysql:latest --default-authentication-plugin=mysql_native_password | |
Just wanna remake the db? | |
docker exec -it database1 mysql -uroot -p | |
mysql> DROP DATABASE database1; | |
mysql> CREATE DATABASE database1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment