10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Docker] Docker for Macでmysqlを起動〜接続

Last updated at Posted at 2017-09-23

手元で複数のバージョンや設定を使い分ける場合に便利。
以下3ステップで起動〜接続まで。

1. mysqlのイメージをdockerhubからpull

docker pull mysql

※ バージョン指定する場合は docker pull mysql:5.6 のようにコロンの後にバージョン(タグ)指定する
※ pull可能なバージョンは以下を参照
https://hub.docker.com/_/mysql/

2. コンテナをビルド&起動

docker run -e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mysql

3. ローカルのmysqlクライアントから接続

mysql -uroot -p -h 127.0.0.1

※ localhostだと名前解決されないようで、 -h 127.0.0.1 を付けないと起動できない

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?