質問編集履歴

3

エラー内容変更

2020/06/04 16:24

投稿

tky106
tky106

スコア3

test CHANGED
@@ -1 +1 @@
1
- railsのdocker環境でmysqlの設定をしたい
1
+ の変更railsのdocker環境でmysqlの設定をしたい
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ```
8
8
 
9
- Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
9
+ Access denied for user 'root'@'172.18.0.3' (using password: NO)
10
10
 
11
11
  ```
12
12
 
@@ -36,34 +36,30 @@
36
36
 
37
37
  - '3306:3306'
38
38
 
39
+ web:
40
+
41
+ build:
42
+
43
+ context: .
44
+
45
+ dockerfile: Dockerfile
46
+
47
+ command: bundle exec rails s -p 3000 -b '0.0.0.0'
48
+
49
+ tty: true
50
+
51
+ stdin_open: true
52
+
53
+ depends_on:
54
+
55
+ - db
56
+
57
+ ports:
58
+
59
+ - "3000:3000"
60
+
39
61
  volumes:
40
62
 
41
- - mysql-data:/var/lib/mysql/data
42
-
43
- web:
44
-
45
- build:
46
-
47
- context: .
48
-
49
- dockerfile: Dockerfile
50
-
51
- command: bundle exec rails s -p 3000 -b '0.0.0.0'
52
-
53
- tty: true
54
-
55
- stdin_open: true
56
-
57
- depends_on:
58
-
59
- - db
60
-
61
- ports:
62
-
63
- - "3000:3000"
64
-
65
- volumes:
66
-
67
63
  - .:/application
68
64
 
69
65
  volumes:
@@ -192,29 +188,17 @@
192
188
 
193
189
  ```
194
190
 
195
-
196
-
197
191
  ```terminal
198
192
 
199
- $ docker ps
200
-
201
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
202
-
203
- f56385f4bcd1 match_hike_web "bundle exec rails s…" 25 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp match_hike_web_1
193
+ $ docker exec -it match_hike_db_1 bash -c "mysql -u root -proot"
204
-
194
+
205
- 65a064d28d7a mysql:5.6.47 "docker-entrypoint.s…" 25 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp match_hike_db_1
195
+ Warning: Using a password on the command line interface can be insecure.
206
-
207
- ```
208
-
209
- ```terminal
210
-
211
- $ mysql -v
212
196
 
213
197
  Welcome to the MySQL monitor. Commands end with ; or \g.
214
198
 
215
- Your MySQL connection id is 62
199
+ Your MySQL connection id is 4
216
-
200
+
217
- Server version: 5.6.47 Homebrew
201
+ Server version: 5.6.47 MySQL Community Server (GPL)
218
202
 
219
203
 
220
204
 
@@ -230,89 +214,47 @@
230
214
 
231
215
 
232
216
 
233
- Reading history-file /Users/tky/.mysql_history
234
-
235
217
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
236
218
 
237
219
 
238
220
 
221
+ mysql> show databases;
222
+
223
+ +------------------------+
224
+
225
+ | Database |
226
+
227
+ +------------------------+
228
+
229
+ | information_schema |
230
+
231
+ | data |
232
+
233
+ | match_hike_development |
234
+
235
+ | mysql |
236
+
237
+ | performance_schema |
238
+
239
+ +------------------------+
240
+
241
+ 5 rows in set (0.04 sec)
242
+
243
+
244
+
239
- mysql>
245
+ mysql>
240
-
246
+
241
- ```
247
+ ```
242
-
243
- ### docker-compose logs db実行
248
+
244
-
245
- ```log
249
+
246
-
247
- db_1 | 2020-06-04 14:29:36+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started.
248
-
249
- db_1 | 2020-06-04 14:29:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
250
-
251
- db_1 | 2020-06-04 14:29:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started.
252
-
253
- db_1 | 2020-06-04 14:29:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
254
-
255
- db_1 | 2020-06-04 14:29:39 0 [Note] mysqld (mysqld 5.6.47) starting as process 1 ...
256
-
257
- db_1 | 2020-06-04 14:29:39 1 [Note] Plugin 'FEDERATED' is disabled.
258
-
259
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
260
-
261
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: The InnoDB memory heap is disabled
262
-
263
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
264
-
265
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Memory barrier is not used
266
-
267
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
268
-
269
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using Linux native AIO
270
-
271
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using CPU crc32 instructions
272
-
273
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
274
-
275
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Completed initialization of buffer pool
276
-
277
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Highest supported file format is Barracuda.
278
-
279
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: 128 rollback segment(s) are active.
280
-
281
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Waiting for purge to start
282
-
283
- db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: 5.6.47 started; log sequence number 1626007
284
-
285
- db_1 | 2020-06-04 14:29:39 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
286
-
287
- db_1 | 2020-06-04 14:29:39 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
288
-
289
- db_1 | 2020-06-04 14:29:39 1 [Note] Server hostname (bind-address): '*'; port: 3306
290
-
291
- db_1 | 2020-06-04 14:29:39 1 [Note] IPv6 is available.
292
-
293
- db_1 | 2020-06-04 14:29:39 1 [Note] - '::' resolves to '::';
294
-
295
- db_1 | 2020-06-04 14:29:39 1 [Note] Server socket created on IP: '::'.
296
-
297
- db_1 | 2020-06-04 14:29:39 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
298
-
299
- db_1 | 2020-06-04 14:29:39 1 [Warning] 'proxies_priv' entry '@ root@65a064d28d7a' ignored in --skip-name-resolve mode.
300
-
301
- db_1 | 2020-06-04 14:29:39 1 [Note] Event Scheduler: Loaded 0 events
302
-
303
- db_1 | 2020-06-04 14:29:39 1 [Note] mysqld: ready for connections.
304
-
305
- db_1 | Version: '5.6.47' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
306
-
307
- ```
308
250
 
309
251
 
310
252
 
311
253
  ### 試したこと
312
254
 
313
- mysqlを起動できていないかと思い、
255
+ volume削除
314
-
256
+
315
- docker run -d -p 3306:3306 mysql を試たが変わらず。
257
+ コンテナの削除、作り直
316
258
 
317
259
 
318
260
 

2

logの追記

2020/06/04 16:24

投稿

tky106
tky106

スコア3

test CHANGED
File without changes
test CHANGED
@@ -192,6 +192,8 @@
192
192
 
193
193
  ```
194
194
 
195
+
196
+
195
197
  ```terminal
196
198
 
197
199
  $ docker ps
@@ -204,8 +206,6 @@
204
206
 
205
207
  ```
206
208
 
207
-
208
-
209
209
  ```terminal
210
210
 
211
211
  $ mysql -v
@@ -240,6 +240,72 @@
240
240
 
241
241
  ```
242
242
 
243
+ ### docker-compose logs db実行
244
+
245
+ ```log
246
+
247
+ db_1 | 2020-06-04 14:29:36+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started.
248
+
249
+ db_1 | 2020-06-04 14:29:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
250
+
251
+ db_1 | 2020-06-04 14:29:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started.
252
+
253
+ db_1 | 2020-06-04 14:29:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
254
+
255
+ db_1 | 2020-06-04 14:29:39 0 [Note] mysqld (mysqld 5.6.47) starting as process 1 ...
256
+
257
+ db_1 | 2020-06-04 14:29:39 1 [Note] Plugin 'FEDERATED' is disabled.
258
+
259
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
260
+
261
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: The InnoDB memory heap is disabled
262
+
263
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
264
+
265
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Memory barrier is not used
266
+
267
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
268
+
269
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using Linux native AIO
270
+
271
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Using CPU crc32 instructions
272
+
273
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
274
+
275
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Completed initialization of buffer pool
276
+
277
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Highest supported file format is Barracuda.
278
+
279
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: 128 rollback segment(s) are active.
280
+
281
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: Waiting for purge to start
282
+
283
+ db_1 | 2020-06-04 14:29:39 1 [Note] InnoDB: 5.6.47 started; log sequence number 1626007
284
+
285
+ db_1 | 2020-06-04 14:29:39 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
286
+
287
+ db_1 | 2020-06-04 14:29:39 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
288
+
289
+ db_1 | 2020-06-04 14:29:39 1 [Note] Server hostname (bind-address): '*'; port: 3306
290
+
291
+ db_1 | 2020-06-04 14:29:39 1 [Note] IPv6 is available.
292
+
293
+ db_1 | 2020-06-04 14:29:39 1 [Note] - '::' resolves to '::';
294
+
295
+ db_1 | 2020-06-04 14:29:39 1 [Note] Server socket created on IP: '::'.
296
+
297
+ db_1 | 2020-06-04 14:29:39 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
298
+
299
+ db_1 | 2020-06-04 14:29:39 1 [Warning] 'proxies_priv' entry '@ root@65a064d28d7a' ignored in --skip-name-resolve mode.
300
+
301
+ db_1 | 2020-06-04 14:29:39 1 [Note] Event Scheduler: Loaded 0 events
302
+
303
+ db_1 | 2020-06-04 14:29:39 1 [Note] mysqld: ready for connections.
304
+
305
+ db_1 | Version: '5.6.47' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
306
+
307
+ ```
308
+
243
309
 
244
310
 
245
311
  ### 試したこと

1

docker ps時のターミナルを追記しました。

2020/06/04 14:39

投稿

tky106
tky106

スコア3

test CHANGED
File without changes
test CHANGED
@@ -194,6 +194,20 @@
194
194
 
195
195
  ```terminal
196
196
 
197
+ $ docker ps
198
+
199
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
200
+
201
+ f56385f4bcd1 match_hike_web "bundle exec rails s…" 25 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp match_hike_web_1
202
+
203
+ 65a064d28d7a mysql:5.6.47 "docker-entrypoint.s…" 25 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp match_hike_db_1
204
+
205
+ ```
206
+
207
+
208
+
209
+ ```terminal
210
+
197
211
  $ mysql -v
198
212
 
199
213
  Welcome to the MySQL monitor. Commands end with ; or \g.
@@ -238,6 +252,10 @@
238
252
 
239
253
  ### 補足情報(FW/ツールのバージョンなど)
240
254
 
255
+ Docker version 19.03.8, build afacb8b
256
+
257
+ macOS
258
+
241
259
  ruby 2.5.1
242
260
 
243
261
  rails 6.0.3.1