teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

Add expression

2020/08/29 14:00

投稿

y_shinoda
y_shinoda

スコア3272

answer CHANGED
@@ -34,4 +34,43 @@
34
34
  mysql>
35
35
  ```
36
36
 
37
- 注: 入力が速すぎると MySQL の起動が間に合わずログインできません
37
+ 注: 入力が速すぎると MySQL の起動が間に合わずログインできません
38
+
39
+ ## 原因
40
+
41
+ 1
42
+ コマンドとして bash を与えてしまうと MySQL は起動しません
43
+
44
+ コマンドを与えなかったとき:
45
+
46
+ ```console
47
+ root@3ca903dc86dd:/# ps -auxww
48
+ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
49
+ mysql 1 1.5 11.7 2123748 359828 pts/0 Ssl+ 13:42 0:00 mysqld
50
+ root 85 0.0 0.1 3868 3212 pts/1 Ss 13:42 0:00 bash
51
+ root 599 0.0 0.0 7640 2652 pts/1 R+ 13:43 0:00 ps -auxww
52
+ ```
53
+
54
+ コマンドとして bash を与えたとき:
55
+
56
+ ```console
57
+ root@94f930f8552c:/# ps -auxww
58
+ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
59
+ root 1 0.0 0.1 3868 3160 pts/0 Ss+ 13:44 0:00 bash
60
+ root 6 0.0 0.1 3868 3264 pts/1 Ss 13:44 0:00 bash
61
+ root 409 0.0 0.0 7640 2620 pts/1 R+ 13:45 0:00 ps -auxww
62
+ ```
63
+
64
+ 2
65
+ 環境変数 `MYSQL_ROOT_PASSWORD` は必須とされています:
66
+ [mysql - Docker Hub](https://hub.docker.com/_/mysql)
67
+
68
+ > Environment Variables
69
+ >
70
+ > MYSQL_ROOT_PASSWORD
71
+ >
72
+ > This variable is mandatory
73
+
74
+ イメージは Docker Hub のトップもしくは GitHub の README.md を読むと使い方が書いてあります
75
+ 特にDocker の公式イメージに関してはほとんどがしっかり書かれているので、
76
+ うまく行かないときは、これに目を通すのが最速で進捗するコツです

1

Add expression

2020/08/29 14:00

投稿

y_shinoda
y_shinoda

スコア3272

answer CHANGED
@@ -11,4 +11,27 @@
11
11
 
12
12
  ```console
13
13
  docker run -itd -e MYSQL_ROOT_PASSWORD="passW0@d" --name test_mysql -p 3306:3306 mysql:latest
14
- ```
14
+ ```
15
+
16
+ ```console
17
+ $ docker run -itd -e MYSQL_ROOT_PASSWORD="passW0@d" --name test_mysql -p 3306:3306 mysql:latest
18
+ 92cdd6876c0e4e0364609cae02e605d7d49f7b67b7c3b88359add7ffca7a685b
19
+ $ docker exec -it test_mysql bash
20
+ root@92cdd6876c0e:/# mysql -h 127.0.0.1 -u root -p
21
+ Enter password:
22
+ Welcome to the MySQL monitor. Commands end with ; or \g.
23
+ Your MySQL connection id is 8
24
+ Server version: 8.0.21 MySQL Community Server - GPL
25
+
26
+ Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
27
+
28
+ Oracle is a registered trademark of Oracle Corporation and/or its
29
+ affiliates. Other names may be trademarks of their respective
30
+ owners.
31
+
32
+ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
33
+
34
+ mysql>
35
+ ```
36
+
37
+ 注: 入力が速すぎると MySQL の起動が間に合わずログインできません