質問編集履歴
12
追記
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
php artisan migrateがうまく行かない
|
1
|
+
php artisan migrateがうまく行かない(docker使用)
|
body
CHANGED
File without changes
|
11
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
+
### エラー
|
4
|
+
```ここに言語を入力
|
5
|
+
コード
|
6
|
+
root@8be8ddaa6767:/var/www/html# php artisan migrate
|
7
|
+
|
8
|
+
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = sample and table_name = migrations and table_type = 'BASE TABLE')
|
9
|
+
|
10
|
+
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
|
11
|
+
665| // If an exception occurs when attempting to run a query, we'll format the error
|
12
|
+
666| // message to include the bindings with SQL, which will make this exception a
|
13
|
+
667| // lot more helpful to the developer instead of just the database's errors.
|
14
|
+
668| catch (Exception $e) {
|
15
|
+
> 669| throw new QueryException(
|
16
|
+
670| $query, $this->prepareBindings($bindings), $e
|
17
|
+
671| );
|
18
|
+
672| }
|
19
|
+
673|
|
20
|
+
|
21
|
+
Exception trace:
|
22
|
+
|
23
|
+
1 PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known")
|
24
|
+
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
25
|
+
|
26
|
+
2 PDO::__construct("mysql:host=db;port=3306;dbname=sample", "hoge", "777", [])
|
27
|
+
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
28
|
+
|
29
|
+
Please use the argument -v to see more details.
|
30
|
+
```
|
3
31
|
### 追記
|
4
32
|
DB_HOSTが異なる場合
|
5
33
|
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
|
@@ -65,9 +93,6 @@
|
|
65
93
|
DB_HOST=db
|
66
94
|
DB_PORT=3306
|
67
95
|
DB_DATABASE=sample
|
68
|
-
# DB_USERNAME=root
|
69
|
-
# DB_PASSWORD=myrdspassword
|
70
|
-
|
71
96
|
```
|
72
97
|
|
73
98
|
docker-compose.yml
|
@@ -150,7 +175,6 @@
|
|
150
175
|
affiliates. Other names may be trademarks of their respective
|
151
176
|
owners.
|
152
177
|
|
153
|
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
154
178
|
|
155
179
|
mysql> select user( );
|
156
180
|
+----------------+
|
10
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
+
### 追記
|
4
|
+
DB_HOSTが異なる場合
|
5
|
+
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
|
6
|
+
となるらしいのでその辺に問題があるかもしれません。調査中ですが、
|
7
|
+
(参考
|
8
|
+
https://qiita.com/mineaki27th/items/2fec99060f1c97ec2892
|
9
|
+
)
|
3
10
|
|
4
|
-
|
5
|
-
|
6
11
|
バージョン
|
7
12
|
php: 7.4.1
|
8
13
|
laravel: 6.20.
|
9
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,10 +8,12 @@
|
|
8
8
|
laravel: 6.20.
|
9
9
|
MySQL version: 8.0.28
|
10
10
|
|
11
|
+
(docker,docker-compose.ymlはサイト・https://qiita.com/shimotaroo/items/29f7878b01ee4b99b951
|
12
|
+
を利用)
|
11
13
|
```ここに言語を入力
|
12
14
|
コード
|
13
15
|
portfolio($docker-compose up -dをここで起動)
|
14
|
-
├─ docker
|
16
|
+
├─ docker
|
15
17
|
│ ├─ php
|
16
18
|
│ │ └─ Dockerfile
|
17
19
|
│ │ └─ php.ini
|
@@ -48,7 +50,7 @@
|
|
48
50
|
コード
|
49
51
|
APP_NAME=docker-laravel-vue
|
50
52
|
APP_ENV=local
|
51
|
-
APP_KEY=
|
53
|
+
APP_KEY=省略
|
52
54
|
APP_DEBUG=true
|
53
55
|
APP_URL=127.0.0.1
|
54
56
|
|
8
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
```ここに言語を入力
|
12
12
|
コード
|
13
|
-
|
13
|
+
portfolio($docker-compose up -dをここで起動)
|
14
14
|
├─ docker(サイト・https://qiita.com/shimotaroo/items/29f7878b01ee4b99b951を利用)
|
15
15
|
│ ├─ php
|
16
16
|
│ │ └─ Dockerfile
|
@@ -22,7 +22,7 @@
|
|
22
22
|
│ └─ Dockerfile
|
23
23
|
│ └─ my.cnf
|
24
24
|
│
|
25
|
-
├─ src(laravelのapp、config,resouses等が入っています)
|
25
|
+
├─ src(laravelのapp、config,resousesや.env等が入っています)
|
26
26
|
│
|
27
27
|
│
|
28
28
|
│─ .env(下)
|
@@ -30,7 +30,7 @@
|
|
30
30
|
└─ docker-compose.yml(下)
|
31
31
|
```
|
32
32
|
|
33
|
-
.env
|
33
|
+
portfolio/.env
|
34
34
|
```ここに言語を入力
|
35
35
|
コード
|
36
36
|
WEB_PORT=80
|
@@ -43,6 +43,26 @@
|
|
43
43
|
DB_ROOT_PASSWORD=secret
|
44
44
|
```
|
45
45
|
|
46
|
+
portfolio/src/.env
|
47
|
+
```ここに言語を入力
|
48
|
+
コード
|
49
|
+
APP_NAME=docker-laravel-vue
|
50
|
+
APP_ENV=local
|
51
|
+
APP_KEY=base64:5uoMq6zuwB2wb4XXHQDBYDcKBjPBbimHbpeHHGaLjOI=
|
52
|
+
APP_DEBUG=true
|
53
|
+
APP_URL=127.0.0.1
|
54
|
+
|
55
|
+
LOG_CHANNEL=stack
|
56
|
+
|
57
|
+
DB_CONNECTION=mysql
|
58
|
+
DB_HOST=db
|
59
|
+
DB_PORT=3306
|
60
|
+
DB_DATABASE=sample
|
61
|
+
# DB_USERNAME=root
|
62
|
+
# DB_PASSWORD=myrdspassword
|
63
|
+
|
64
|
+
```
|
65
|
+
|
46
66
|
docker-compose.yml
|
47
67
|
```ここに言語を入力
|
48
68
|
コード
|
7
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,11 +37,9 @@
|
|
37
37
|
DB_PORT=3306
|
38
38
|
//docker-compose.yml内のdb
|
39
39
|
DB_HOSTURL=db
|
40
|
-
|
41
|
-
DB_CONNECTION=mysql
|
42
|
-
DB_NAME=
|
40
|
+
DB_NAME=sample
|
43
|
-
DB_USER=
|
41
|
+
DB_USER=hoge
|
44
|
-
DB_PASSWORD=
|
42
|
+
DB_PASSWORD=777
|
45
43
|
DB_ROOT_PASSWORD=secret
|
46
44
|
```
|
47
45
|
|
@@ -95,7 +93,6 @@
|
|
95
93
|
TZ: 'Asia/Tokyo'
|
96
94
|
volumes:
|
97
95
|
- mysql-volume:/var/lib/mysql
|
98
|
-
|
99
96
|
|
100
97
|
```
|
101
98
|
|
6
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -106,53 +106,18 @@
|
|
106
106
|
|
107
107
|
|
108
108
|
ターミナルに打ち込んだ時に得られる情報
|
109
|
+
|
110
|
+
localのmysql詳細
|
109
111
|
```ここに言語を入力
|
110
112
|
コード
|
111
|
-
masa@MasaakinoMacBook-Air
|
113
|
+
masa@MasaakinoMacBook-Air portfolio % pwd
|
112
|
-
root@64071ebca710:/var/www/html# pwd
|
113
|
-
/var/www/html
|
114
|
-
|
114
|
+
/Users/masa/Desktop/portfolio
|
115
|
-
README.md artisan composer.json config node_modules package.json portfolio resources server.php tests webpack.mix.js
|
116
|
-
app bootstrap composer.lock database package-lock.json phpunit.xml public routes storage vendor
|
117
|
-
root@64071ebca710:/var/www/html# php artisan config:cache & php artisan cache:clear & php artisan migrate:refresh (キャッシュを消してからマイグレーションする)
|
118
|
-
[1] 17
|
119
|
-
[2] 18
|
120
|
-
Configuration cache cleared!
|
121
|
-
Application cache cleared!
|
122
|
-
Configuration cached successfully!
|
123
115
|
|
124
|
-
|
125
|
-
|
126
|
-
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
|
127
|
-
665| // If an exception occurs when attempting to run a query, we'll format the error
|
128
|
-
666| // message to include the bindings with SQL, which will make this exception a
|
129
|
-
667| // lot more helpful to the developer instead of just the database's errors.
|
130
|
-
668| catch (Exception $e) {
|
131
|
-
> 669| throw new QueryException(
|
132
|
-
670| $query, $this->prepareBindings($bindings), $e
|
133
|
-
671| );
|
134
|
-
672| }
|
135
|
-
673|
|
136
|
-
|
137
|
-
Exception trace:
|
138
|
-
|
139
|
-
1 PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known")
|
140
|
-
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
141
|
-
|
142
|
-
2 PDO::__construct("mysql:host=db;port=3306;dbname=mysql", "root", "secret", [])
|
143
|
-
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
144
|
-
|
145
|
-
Please use the argument -v to see more details.
|
146
|
-
[1]- Done php artisan config:cache
|
147
|
-
[2]+ Done php artisan cache:clear
|
148
|
-
root@64071ebca710:/var/www/html# exit
|
149
|
-
exit
|
150
|
-
masa@MasaakinoMacBook-Air docker-laravel-vue % pwd
|
151
|
-
/Users/masa/Desktop/portfolio
|
152
|
-
masa@MasaakinoMacBook-Air docker-laravel-vue % mysql -u root -p
|
116
|
+
masa@MasaakinoMacBook-Air portfolio % mysql -u hoge -p sample;
|
153
117
|
Enter password:
|
118
|
+
//『777』を入力
|
154
119
|
Welcome to the MySQL monitor. Commands end with ; or \g.
|
155
|
-
Your MySQL connection id is
|
120
|
+
Your MySQL connection id is 27
|
156
121
|
Server version: 8.0.28 Homebrew
|
157
122
|
|
158
123
|
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
|
@@ -163,117 +128,127 @@
|
|
163
128
|
|
164
129
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
165
130
|
|
131
|
+
mysql> select user( );
|
132
|
+
+----------------+
|
133
|
+
| user( ) |
|
134
|
+
+----------------+
|
135
|
+
| hoge@localhost |
|
136
|
+
+----------------+
|
137
|
+
1 row in set (0.00 sec)
|
138
|
+
|
166
139
|
mysql> show databases;
|
167
140
|
+--------------------+
|
168
141
|
| Database |
|
169
142
|
+--------------------+
|
170
143
|
| information_schema |
|
171
|
-
| mysql |
|
172
|
-
| performance_schema |
|
173
|
-
|
|
144
|
+
| sample |
|
174
|
-
| sys |
|
175
|
-
| todo |
|
176
145
|
+--------------------+
|
177
|
-
|
146
|
+
2 rows in set (0.01 sec)
|
178
147
|
|
179
|
-
mysql> SELECT
|
148
|
+
mysql> SELECT DATABASE();
|
180
|
-
+------------
|
149
|
+
+------------+
|
181
|
-
|
|
150
|
+
| DATABASE() |
|
182
|
-
+------------
|
151
|
+
+------------+
|
183
|
-
| admin | localhost | caching_sha2_password |
|
184
|
-
|
|
152
|
+
| sample |
|
185
|
-
| mysql.session | localhost | caching_sha2_password |
|
186
|
-
| mysql.sys | localhost | caching_sha2_password |
|
187
|
-
| root | localhost | mysql_native_password |
|
188
|
-
+------------
|
153
|
+
+------------+
|
189
|
-
|
154
|
+
1 row in set (0.00 sec)
|
190
155
|
|
191
|
-
mysql> use mysql;
|
192
|
-
Reading table information for completion of table and column names
|
193
|
-
You can turn off this feature to get a quicker startup with -A
|
194
156
|
|
157
|
+
mysql> use sample;
|
195
158
|
Database changed
|
196
|
-
mysql> show table;
|
197
|
-
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
198
|
-
mysql>
|
159
|
+
mysql> SELECT DATABASE();
|
199
|
-
+------------
|
160
|
+
+------------+
|
200
|
-
|
|
161
|
+
| DATABASE() |
|
201
|
-
+------------
|
162
|
+
+------------+
|
202
|
-
| columns_priv |
|
203
|
-
| component |
|
204
|
-
| db |
|
205
|
-
| default_roles |
|
206
|
-
| engine_cost |
|
207
|
-
| func |
|
208
|
-
| general_log |
|
209
|
-
| global_grants |
|
210
|
-
| gtid_executed |
|
211
|
-
| help_category |
|
212
|
-
| help_keyword |
|
213
|
-
| help_relation |
|
214
|
-
| help_topic |
|
215
|
-
| innodb_index_stats |
|
216
|
-
| innodb_table_stats |
|
217
|
-
| password_history |
|
218
|
-
| plugin |
|
219
|
-
| procs_priv |
|
220
|
-
| proxies_priv |
|
221
|
-
| replication_asynchronous_connection_failover |
|
222
|
-
| replication_asynchronous_connection_failover_managed |
|
223
|
-
| replication_group_configuration_version |
|
224
|
-
| replication_group_member_actions |
|
225
|
-
| role_edges |
|
226
|
-
| server_cost |
|
227
|
-
| servers |
|
228
|
-
|
|
163
|
+
| sample |
|
229
|
-
| slave_relay_log_info |
|
230
|
-
| slave_worker_info |
|
231
|
-
| slow_log |
|
232
|
-
| tables_priv |
|
233
|
-
| time_zone |
|
234
|
-
| time_zone_leap_second |
|
235
|
-
| time_zone_name |
|
236
|
-
| time_zone_transition |
|
237
|
-
| time_zone_transition_type |
|
238
|
-
| user |
|
239
|
-
+------------
|
164
|
+
+------------+
|
240
|
-
|
165
|
+
1 row in set (0.00 sec)
|
241
166
|
|
242
|
-
//MySQL version: 8.0.28 以降ではmysql_native_password でなくてもデフォルトのcaching_sha2_password でいけることと、
|
243
|
-
//mysql_native_password で試してうまく行かなかったことから caching_sha2_password にして再度
|
244
|
-
//試しましたがダメでした
|
245
|
-
mysql> SELECT user, host, plugin FROM mysql.user;
|
246
|
-
+------------------+-----------+-----------------------+
|
247
|
-
| user | host | plugin |
|
248
|
-
+------------------+-----------+-----------------------+
|
249
|
-
| admin | localhost | caching_sha2_password |
|
250
|
-
| mysql.infoschema | localhost | caching_sha2_password |
|
251
|
-
| mysql.session | localhost | caching_sha2_password |
|
252
|
-
| mysql.sys | localhost | caching_sha2_password |
|
253
|
-
| root | localhost | mysql_native_password |
|
254
|
-
+------------------+-----------+-----------------------+
|
255
|
-
|
167
|
+
mysql> exit
|
168
|
+
Bye
|
256
169
|
|
170
|
+
masa@MasaakinoMacBook-Air portfolio % mysql -u root -p
|
171
|
+
Enter password:
|
172
|
+
//『secret』を入力
|
257
|
-
|
173
|
+
Welcome to the MySQL monitor. Commands end with ; or \g.
|
258
|
-
|
174
|
+
Your MySQL connection id is 30
|
175
|
+
Server version: 8.0.28 Homebrew
|
259
176
|
|
260
|
-
|
177
|
+
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
|
261
|
-
+------------------+-----------+-----------------------+
|
262
|
-
| user | host | plugin |
|
263
|
-
+------------------+-----------+-----------------------+
|
264
|
-
| admin | localhost | caching_sha2_password |
|
265
|
-
| mysql.infoschema | localhost | caching_sha2_password |
|
266
|
-
| mysql.session | localhost | caching_sha2_password |
|
267
|
-
| mysql.sys | localhost | caching_sha2_password |
|
268
|
-
| root | localhost | caching_sha2_password |
|
269
|
-
+------------------+-----------+-----------------------+
|
270
|
-
5 rows in set (0.00 sec)
|
271
178
|
|
179
|
+
Oracle is a registered trademark of Oracle Corporation and/or its
|
180
|
+
affiliates. Other names may be trademarks of their respective
|
181
|
+
owners.
|
182
|
+
|
183
|
+
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
184
|
+
|
272
|
-
mysql>
|
185
|
+
mysql>
|
186
|
+
|
273
|
-
|
187
|
+
```
|
188
|
+
|
189
|
+
実際のphp artisan migrateがうまく行かない部分の詳細
|
190
|
+
```ここに言語を入力
|
191
|
+
コード
|
274
|
-
masa@MasaakinoMacBook-Air
|
192
|
+
masa@MasaakinoMacBook-Air portfolio % mysql.server restart
|
275
193
|
Shutting down MySQL
|
276
194
|
. SUCCESS!
|
277
195
|
Starting MySQL
|
278
|
-
. SUCCESS!
|
196
|
+
.. SUCCESS!
|
197
|
+
masa@MasaakinoMacBook-Air portfolio % docker-compose down
|
198
|
+
[+] Running 4/4
|
199
|
+
⠿ Container portfolio-db-1 Removed 0.1s
|
200
|
+
⠿ Container portfolio-web-1 Removed 0.3s
|
201
|
+
⠿ Container portfolio-app-1 Removed 0.3s
|
202
|
+
⠿ Network portfolio_default Removed 0.1s
|
203
|
+
masa@MasaakinoMacBook-Air portfolio % docker builder prune & docker volume prune
|
204
|
+
[1] 17257
|
205
|
+
WARNING! This will remove all local volumes not used by at least one container.
|
206
|
+
Are you sure you want to continue? [y/N] WARNING! This will remove all dangling build cache. Are you sure you want to continue? [y/N]
|
207
|
+
Total reclaimed space: 0B
|
208
|
+
masa@MasaakinoMacBook-Air portfolio % docker-compose up -d
|
209
|
+
[+] Running 4/4
|
210
|
+
⠿ Network portfolio_default Created 0.1s
|
211
|
+
⠿ Container portfolio-app-1 Started 4.3s
|
212
|
+
⠿ Container portfolio-db-1 Started 1.4s
|
213
|
+
⠿ Container portfolio-web-1 Started 5.1s
|
214
|
+
masa@MasaakinoMacBook-Air portfolio % docker-compose exec app bash
|
215
|
+
root@8be8ddaa6767:/var/www/html# pwd
|
216
|
+
/var/www/html
|
217
|
+
root@8be8ddaa6767:/var/www/html# ls -a
|
218
|
+
. .editorconfig .env.testing .gitignore .styleci.yml app bootstrap composer.lock database package-lock.json phpunit.xml resources server.php tests webpack.mix.js
|
219
|
+
.. .env .gitattributes .phpunit.result.cache README.md artisan composer.json config node_modules package.json public routes storage vendor
|
220
|
+
|
221
|
+
root@8be8ddaa6767:/var/www/html# php artisan config:cache
|
222
|
+
Configuration cache cleared!
|
223
|
+
Configuration cached successfully!
|
224
|
+
root@8be8ddaa6767:/var/www/html# php artisan config:clear
|
225
|
+
Configuration cache cleared!
|
226
|
+
root@8be8ddaa6767:/var/www/html# php artisan cache:clear
|
227
|
+
Application cache cleared!
|
228
|
+
root@8be8ddaa6767:/var/www/html# php artisan migrate
|
229
|
+
|
230
|
+
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = sample and table_name = migrations and table_type = 'BASE TABLE')
|
231
|
+
|
232
|
+
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
|
233
|
+
665| // If an exception occurs when attempting to run a query, we'll format the error
|
234
|
+
666| // message to include the bindings with SQL, which will make this exception a
|
235
|
+
667| // lot more helpful to the developer instead of just the database's errors.
|
236
|
+
668| catch (Exception $e) {
|
237
|
+
> 669| throw new QueryException(
|
238
|
+
670| $query, $this->prepareBindings($bindings), $e
|
239
|
+
671| );
|
240
|
+
672| }
|
241
|
+
673|
|
242
|
+
|
243
|
+
Exception trace:
|
244
|
+
|
245
|
+
1 PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known")
|
246
|
+
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
247
|
+
|
248
|
+
2 PDO::__construct("mysql:host=db;port=3306;dbname=sample", "hoge", "777", [])
|
249
|
+
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
250
|
+
|
251
|
+
Please use the argument -v to see more details.
|
252
|
+
root@8be8ddaa6767:/var/www/html#
|
253
|
+
|
279
254
|
```
|
5
追記
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
php artisan migrateがうまく行かない
|
1
|
+
php artisan migrateがうまく行かない
|
body
CHANGED
File without changes
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -239,6 +239,36 @@
|
|
239
239
|
+------------------------------------------------------+
|
240
240
|
37 rows in set (0.00 sec)
|
241
241
|
|
242
|
+
//MySQL version: 8.0.28 以降ではmysql_native_password でなくてもデフォルトのcaching_sha2_password でいけることと、
|
243
|
+
//mysql_native_password で試してうまく行かなかったことから caching_sha2_password にして再度
|
244
|
+
//試しましたがダメでした
|
245
|
+
mysql> SELECT user, host, plugin FROM mysql.user;
|
246
|
+
+------------------+-----------+-----------------------+
|
247
|
+
| user | host | plugin |
|
248
|
+
+------------------+-----------+-----------------------+
|
249
|
+
| admin | localhost | caching_sha2_password |
|
250
|
+
| mysql.infoschema | localhost | caching_sha2_password |
|
251
|
+
| mysql.session | localhost | caching_sha2_password |
|
252
|
+
| mysql.sys | localhost | caching_sha2_password |
|
253
|
+
| root | localhost | mysql_native_password |
|
254
|
+
+------------------+-----------+-----------------------+
|
255
|
+
5 rows in set (0.00 sec)
|
256
|
+
|
257
|
+
mysql> ALTER USER root@localhost IDENTIFIED WITH caching_sha2_password BY 'secret';
|
258
|
+
Query OK, 0 rows affected (0.01 sec)
|
259
|
+
|
260
|
+
mysql> SELECT user, host, plugin FROM mysql.user;
|
261
|
+
+------------------+-----------+-----------------------+
|
262
|
+
| user | host | plugin |
|
263
|
+
+------------------+-----------+-----------------------+
|
264
|
+
| admin | localhost | caching_sha2_password |
|
265
|
+
| mysql.infoschema | localhost | caching_sha2_password |
|
266
|
+
| mysql.session | localhost | caching_sha2_password |
|
267
|
+
| mysql.sys | localhost | caching_sha2_password |
|
268
|
+
| root | localhost | caching_sha2_password |
|
269
|
+
+------------------+-----------+-----------------------+
|
270
|
+
5 rows in set (0.00 sec)
|
271
|
+
|
242
272
|
mysql> exit
|
243
273
|
Bye
|
244
274
|
masa@MasaakinoMacBook-Air docker-laravel-vue % mysql.server restart //このコマンドは毎回使用
|
@@ -247,7 +277,3 @@
|
|
247
277
|
Starting MySQL
|
248
278
|
. SUCCESS!
|
249
279
|
```
|
250
|
-
|
251
|
-
参考文献
|
252
|
-
DB_HOSTURL=dbの部分について
|
253
|
-
https://yama-weblog.com/does-not-work-php-artisan-migrate-in-docker-environment/
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
バージョン
|
7
|
-
php: 7.
|
7
|
+
php: 7.4.1
|
8
8
|
laravel: 6.20.
|
9
9
|
MySQL version: 8.0.28
|
10
10
|
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
-
・・追記・・
|
4
|
-
エラー文中の
|
5
|
-
PDO::__construct("mysql:host=db;port=3306;dbname=mysql", "root", "secret", [])
|
6
|
-
の[ ]部分の意味がよくわからないのですがこれが原因?の可能性もあるかもしれないので現在進行形で調べて行きたいと思います。
|
7
3
|
|
8
4
|
|
5
|
+
|
9
6
|
バージョン
|
10
7
|
php: 7.2.5
|
11
8
|
laravel: 6.20.
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
+
・・追記・・
|
4
|
+
エラー文中の
|
5
|
+
PDO::__construct("mysql:host=db;port=3306;dbname=mysql", "root", "secret", [])
|
6
|
+
の[ ]部分の意味がよくわからないのですがこれが原因?の可能性もあるかもしれないので現在進行形で調べて行きたいと思います。
|
7
|
+
|
8
|
+
|
3
9
|
バージョン
|
4
10
|
php: 7.2.5
|
5
11
|
laravel: 6.20.
|