Last active
October 11, 2017 01:19
-
-
Save astrsk-hori/ff51ab49004ebbfe1af9 to your computer and use it in GitHub Desktop.
dockerでmysqlを使う ref: http://qiita.com/astrsk_hori/items/e3d6c237d68be1a6f548
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
docker pull mysql | |
docker run --name mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql | |
# 接続確認 passwordはmysqlになります。 | |
mysql -h $(boot2docker ip) -uroot -p |
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
docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
e5edc5732d78 mysql:latest "/entrypoint.sh mysq 49 minutes ago Up 33 minutes 0.0.0.0:3306->3306/tcp mysql | |
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
$ docker exec -it e5edc5732d78 bash | |
$ mysql -u root -p | |
Enter password: | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 3 | |
Server version: 5.6.24 MySQL Community Server (GPL) | |
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. | |
Oracle is a registered trademark of Oracle Corporation and/or its | |
affiliates. Other names may be trademarks of their respective | |
owners. | |
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. | |
mysql> |
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
$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
e5edc5732d78 mysql:latest "/entrypoint.sh mysq 49 minutes ago Up 33 minutes 0.0.0.0:3306->3306/tcp mysql | |
# 停止 | |
docker stop e5edc5732d78 | |
# 削除 | |
docker rm e5edc5732d78 |
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
docker pull busybox | |
# 永続化のためのデータ領域を作成 | |
docker run -v /var/lib/mysql --name mysql_data busybox |
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
docker run --volumes-from mysql_data --name mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql |
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
docker run --name NAME -h HOSTNAME --volumes-from mysql_data --link mysql:ALIAS_MYSQL -i -t -d HOGE_APP |
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 -h ALIAS_MYSQL -uroot -p |
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 -h ALIAS_MYSQL -uroot -p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment