LoginSignup
1
0

More than 3 years have passed since last update.

docker で mysql を使う

Posted at

mysql の docker image を使いたかった。
https://hub.docker.com/_/mysql

docker run

docker image の取得と container 起動。

# docker image
$ docker run --name sql-for-programmer \
    -e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.17

docker start

container が停止していた場合は実行が必要。
docker run の直後なら必要なし。

$ docker start sql-for-programmer

docker exec

mysql cli を経由して接続する。

$ docker exec -it sql-for-programmer \
    mysql -uroot -p -h 127.0.0.1

Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>

docker で mysql が使えるようになった。

1
0
1

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
1
0