質問編集履歴
4
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -435,3 +435,9 @@
|
|
435
435
|
|
436
436
|
|
437
437
|
と変わりませんでした。
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
もちろんパスワードはあってるはずです。
|
442
|
+
|
443
|
+
mysql -u root -pで打ったときにそのパスワードを打ったらちゃんとログイン出来なたので、
|
3
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,9 +58,7 @@
|
|
58
58
|
|
59
59
|
environment:
|
60
60
|
|
61
|
-
MYSQL_ROOT_PASSWORD:
|
61
|
+
MYSQL_ROOT_PASSWORD: 生のパスワード
|
62
|
-
|
63
|
-
MYSQL_DATABASE: root
|
64
62
|
|
65
63
|
ports:
|
66
64
|
|
@@ -285,3 +283,155 @@
|
|
285
283
|
|
286
284
|
|
287
285
|
とエラーが出ました
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
```
|
290
|
+
|
291
|
+
docker-compose down
|
292
|
+
|
293
|
+
```
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
```
|
298
|
+
|
299
|
+
rm -rf tmp/db
|
300
|
+
|
301
|
+
```
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
```
|
306
|
+
|
307
|
+
docker-compose up -d --build
|
308
|
+
|
309
|
+
```
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
と打ち込んでも
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
エラー内容が
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
```
|
322
|
+
|
323
|
+
soichirohara@SoichironoMBP coffee_passport % docker-compose run web rails db:create
|
324
|
+
|
325
|
+
Creating coffee_passport_web_run ... done
|
326
|
+
|
327
|
+
Access denied for user 'root'@'172.21.0.4' (using password: NO)
|
328
|
+
|
329
|
+
Couldn't create 'coffee_passport_development' database. Please check your configuration.
|
330
|
+
|
331
|
+
rails aborted!
|
332
|
+
|
333
|
+
Mysql2::Error::ConnectionError: Access denied for user 'root'@'172.21.0.4' (using password: NO)
|
334
|
+
|
335
|
+
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect'
|
336
|
+
|
337
|
+
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
|
338
|
+
|
339
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `new'
|
340
|
+
|
341
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `mysql2_connection'
|
342
|
+
|
343
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
|
344
|
+
|
345
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
|
346
|
+
|
347
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
|
348
|
+
|
349
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
|
350
|
+
|
351
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
|
352
|
+
|
353
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
|
354
|
+
|
355
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
|
356
|
+
|
357
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
|
358
|
+
|
359
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_handling.rb:189:in `connection'
|
360
|
+
|
361
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `connection'
|
362
|
+
|
363
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/mysql_database_tasks.rb:16:in `create'
|
364
|
+
|
365
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:126:in `create'
|
366
|
+
|
367
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:185:in `block in create_current'
|
368
|
+
|
369
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:479:in `block (2 levels) in each_current_configuration'
|
370
|
+
|
371
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:476:in `each'
|
372
|
+
|
373
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:476:in `block in each_current_configuration'
|
374
|
+
|
375
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:475:in `each'
|
376
|
+
|
377
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:475:in `each_current_configuration'
|
378
|
+
|
379
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
|
380
|
+
|
381
|
+
/usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/railties/databases.rake:39:in `block (2 levels) in <main>'
|
382
|
+
|
383
|
+
/usr/local/bundle/gems/railties-6.0.3.4/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
|
384
|
+
|
385
|
+
/usr/local/bundle/gems/railties-6.0.3.4/lib/rails/commands/rake/rake_command.rb:20:in `perform'
|
386
|
+
|
387
|
+
/usr/local/bundle/gems/railties-6.0.3.4/lib/rails/command.rb:48:in `invoke'
|
388
|
+
|
389
|
+
/usr/local/bundle/gems/railties-6.0.3.4/lib/rails/commands.rb:18:in `<main>'
|
390
|
+
|
391
|
+
/usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
|
392
|
+
|
393
|
+
/usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
|
394
|
+
|
395
|
+
/usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
|
396
|
+
|
397
|
+
/usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
|
398
|
+
|
399
|
+
/usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
|
400
|
+
|
401
|
+
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
|
402
|
+
|
403
|
+
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
|
404
|
+
|
405
|
+
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
|
406
|
+
|
407
|
+
/coffee_passport/bin/rails:9:in `<top (required)>'
|
408
|
+
|
409
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
|
410
|
+
|
411
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
|
412
|
+
|
413
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
|
414
|
+
|
415
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
|
416
|
+
|
417
|
+
/usr/local/bundle/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
|
418
|
+
|
419
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
|
420
|
+
|
421
|
+
/usr/local/bundle/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
|
422
|
+
|
423
|
+
/coffee_passport/bin/spring:15:in `<top (required)>'
|
424
|
+
|
425
|
+
bin/rails:3:in `load'
|
426
|
+
|
427
|
+
bin/rails:3:in `<main>'
|
428
|
+
|
429
|
+
Tasks: TOP => db:create
|
430
|
+
|
431
|
+
(See full trace by running task with --trace)
|
432
|
+
|
433
|
+
```
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
と変わりませんでした。
|
2
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -253,3 +253,35 @@
|
|
253
253
|
|
254
254
|
|
255
255
|
とエラーが出ました。
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
docker-compose.ymlの
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
```
|
264
|
+
|
265
|
+
MYSQL_ROOT_PASSWORD: 生のパスワード
|
266
|
+
|
267
|
+
```
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
を打ち込んで
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
docker-compose run web rails db:create
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
を実行しても
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
Access denied for user 'root'@'172.26.0.4' (using password: NO)
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
とエラーが出ました
|
1
最新のコードへ変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,190 +54,164 @@
|
|
54
54
|
|
55
55
|
db:
|
56
56
|
|
57
|
-
image: mysql:
|
57
|
+
image: mysql:5.7
|
58
58
|
|
59
59
|
environment:
|
60
60
|
|
61
|
+
MYSQL_ROOT_PASSWORD: root
|
62
|
+
|
61
|
-
MYSQL_
|
63
|
+
MYSQL_DATABASE: root
|
64
|
+
|
65
|
+
ports:
|
66
|
+
|
67
|
+
- '3306:3306'
|
68
|
+
|
69
|
+
command: --default-authentication-plugin=mysql_native_password
|
70
|
+
|
71
|
+
volumes:
|
72
|
+
|
73
|
+
- ./tmp/db:/var/lib/mysql
|
74
|
+
|
75
|
+
web:
|
76
|
+
|
77
|
+
build: .
|
78
|
+
|
79
|
+
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
80
|
+
|
81
|
+
volumes:
|
82
|
+
|
83
|
+
- .:/coffee_passport
|
84
|
+
|
85
|
+
ports:
|
86
|
+
|
87
|
+
- "3000:3000"
|
88
|
+
|
89
|
+
depends_on:
|
90
|
+
|
91
|
+
- db
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
default: &default
|
102
|
+
|
103
|
+
adapter: mysql2
|
104
|
+
|
105
|
+
encoding: utf8
|
106
|
+
|
107
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
108
|
+
|
109
|
+
username: root
|
110
|
+
|
111
|
+
password: <%= ENV['MYSQL_PASSWORD'] %>
|
112
|
+
|
113
|
+
socket: /tmp/mysql.sock
|
114
|
+
|
115
|
+
host: db
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
development:
|
120
|
+
|
121
|
+
<<: *default
|
122
|
+
|
123
|
+
database: coffee_passport_development
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
# Warning: The database defined as "test" will be erased and
|
132
|
+
|
133
|
+
# re-generated from your development database when you run "rake".
|
134
|
+
|
135
|
+
# Do not set this db to the same as development or production.
|
136
|
+
|
137
|
+
test:
|
138
|
+
|
139
|
+
<<: *default
|
140
|
+
|
141
|
+
database: coffee_passport_test
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
# As with config/credentials.yml, you never want to store sensitive information,
|
148
|
+
|
149
|
+
# like your database password, in your source code. If your source code is
|
150
|
+
|
151
|
+
# ever seen by anyone, they now have access to your database.
|
152
|
+
|
153
|
+
#
|
154
|
+
|
155
|
+
# Instead, provide the password as a unix environment variable when you boot
|
156
|
+
|
157
|
+
# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
158
|
+
|
159
|
+
# for a full rundown on how to provide these environment variables in a
|
160
|
+
|
161
|
+
# production deployment.
|
162
|
+
|
163
|
+
#
|
164
|
+
|
165
|
+
# On Heroku and other platform providers, you may have a full connection URL
|
166
|
+
|
167
|
+
# available as an environment variable. For example:
|
168
|
+
|
169
|
+
#
|
170
|
+
|
171
|
+
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
|
172
|
+
|
173
|
+
#
|
174
|
+
|
175
|
+
# You can use this database configuration with:
|
176
|
+
|
177
|
+
#
|
178
|
+
|
179
|
+
# production:
|
180
|
+
|
181
|
+
# url: <%= ENV['DATABASE_URL'] %>
|
182
|
+
|
183
|
+
#
|
184
|
+
|
185
|
+
production:
|
186
|
+
|
187
|
+
<<: *default
|
188
|
+
|
189
|
+
database: coffee_passport_production
|
190
|
+
|
191
|
+
username: root
|
192
|
+
|
193
|
+
password: <%= ENV['MYSQL_PASSWORD'] %>
|
194
|
+
|
195
|
+
socket: /var/lib/mysql/mysql.sock
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
### 試したこと
|
202
|
+
|
203
|
+
|
62
204
|
|
63
205
|
MYSQL_ROOT_PASSWORD: <%= ENV['DATABASE_PASSWORD'] %>
|
64
206
|
|
65
|
-
|
207
|
+
|
66
|
-
|
67
|
-
|
208
|
+
|
68
|
-
|
69
|
-
command: --default-authentication-plugin=mysql_native_password
|
70
|
-
|
71
|
-
volumes:
|
72
|
-
|
73
|
-
- ./tmp/db:/var/lib/mysql
|
74
|
-
|
75
|
-
web:
|
76
|
-
|
77
|
-
build: .
|
78
|
-
|
79
|
-
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
80
|
-
|
81
|
-
volumes:
|
82
|
-
|
83
|
-
- .:/coffee_passport
|
84
|
-
|
85
|
-
ports:
|
86
|
-
|
87
|
-
- "3000:3000"
|
88
|
-
|
89
|
-
depends_on:
|
90
|
-
|
91
|
-
- db
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
```
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
```
|
100
|
-
|
101
|
-
# MySQL. Versions 5.5.8 and up are supported.
|
102
|
-
|
103
|
-
#
|
104
|
-
|
105
|
-
# Install the MySQL driver
|
106
|
-
|
107
|
-
# gem install mysql2
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
# Ensure the MySQL gem is defined in your Gemfile
|
112
|
-
|
113
|
-
# gem 'mysql2'
|
114
|
-
|
115
|
-
#
|
116
|
-
|
117
|
-
# And be sure to use new-style password hashing:
|
118
|
-
|
119
|
-
# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
|
120
|
-
|
121
|
-
#
|
122
|
-
|
123
|
-
default: &default
|
124
|
-
|
125
|
-
|
209
|
+
を上記の通りに追記したり、
|
126
|
-
|
127
|
-
encoding: utf8mb4
|
128
|
-
|
129
|
-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
130
210
|
|
131
211
|
username: root
|
132
212
|
|
133
213
|
password: <%= ENV['DATABASE_PASSWORD'] %>
|
134
214
|
|
135
|
-
socket: /tmp/mysql.sock
|
136
|
-
|
137
|
-
host: db
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
development:
|
142
|
-
|
143
|
-
<<: *default
|
144
|
-
|
145
|
-
database: coffee_passport_development
|
146
|
-
|
147
|
-
username: root
|
148
|
-
|
149
|
-
host: db
|
150
|
-
|
151
|
-
username: root
|
152
|
-
|
153
|
-
password: <%= ENV['DATABASE_PASSWORD'] %>
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
# Warning: The database defined as "test" will be erased and
|
160
|
-
|
161
|
-
# re-generated from your development database when you run "rake".
|
162
|
-
|
163
|
-
# Do not set this db to the same as development or production.
|
164
|
-
|
165
|
-
test:
|
166
|
-
|
167
|
-
<<: *default
|
168
|
-
|
169
|
-
database: coffee_passport_test
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
# As with config/credentials.yml, you never want to store sensitive information,
|
174
|
-
|
175
|
-
# like your database password, in your source code. If your source code is
|
176
|
-
|
177
|
-
# ever seen by anyone, they now have access to your database.
|
178
|
-
|
179
|
-
#
|
180
|
-
|
181
|
-
# Instead, provide the password as a unix environment variable when you boot
|
182
|
-
|
183
|
-
# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
184
|
-
|
185
|
-
# for a full rundown on how to provide these environment variables in a
|
186
|
-
|
187
|
-
# production deployment.
|
188
|
-
|
189
|
-
#
|
190
|
-
|
191
|
-
# On Heroku and other platform providers, you may have a full connection URL
|
192
|
-
|
193
|
-
# available as an environment variable. For example:
|
194
|
-
|
195
|
-
#
|
196
|
-
|
197
|
-
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
|
198
|
-
|
199
|
-
#
|
200
|
-
|
201
|
-
# You can use this database configuration with:
|
202
|
-
|
203
|
-
#
|
204
|
-
|
205
|
-
# production:
|
206
|
-
|
207
|
-
# url: <%= ENV['DATABASE_URL'] %>
|
208
|
-
|
209
|
-
#
|
210
|
-
|
211
|
-
production:
|
212
|
-
|
213
|
-
<<: *default
|
214
|
-
|
215
|
-
database: coffee_passport_production
|
216
|
-
|
217
|
-
username: root
|
218
|
-
|
219
|
-
password: <%= ENV['DATABASE_PASSWORD'] %>
|
220
|
-
|
221
|
-
socket: /var/lib/mysql/mysql.sock
|
222
|
-
|
223
|
-
```
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
### 試したこと
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
MYSQL_ROOT_PASSWORD: <%= ENV['DATABASE_PASSWORD'] %>
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
を上記の通りに追記したり、
|
236
|
-
|
237
|
-
username: root
|
238
|
-
|
239
|
-
password: <%= ENV['DATABASE_PASSWORD'] %>
|
240
|
-
|
241
215
|
をdatabase.ymlに追加したりしました。
|
242
216
|
|
243
217
|
|
@@ -266,8 +240,16 @@
|
|
266
240
|
|
267
241
|
|
268
242
|
|
269
|
-
|
243
|
+
db:
|
270
|
-
|
271
|
-
|
272
|
-
|
244
|
+
|
273
|
-
|
245
|
+
image: mysql:5.7
|
246
|
+
|
247
|
+
に変更したら
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-2)
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
とエラーが出ました。
|