質問編集履歴
12
追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
php artisan migrateがうまく行かない
|
1
|
+
php artisan migrateがうまく行かない(docker使用)
|
test
CHANGED
File without changes
|
11
追記
test
CHANGED
File without changes
|
test
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
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
-
|
3
|
+
### 追記
|
4
|
-
|
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
|
+
)
|
5
10
|
|
6
11
|
バージョン
|
7
12
|
php: 7.4.1
|
9
追記
test
CHANGED
File without changes
|
test
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
追記
test
CHANGED
File without changes
|
test
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
|
@@ -41,6 +41,26 @@
|
|
41
41
|
DB_USER=hoge
|
42
42
|
DB_PASSWORD=777
|
43
43
|
DB_ROOT_PASSWORD=secret
|
44
|
+
```
|
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
|
+
|
44
64
|
```
|
45
65
|
|
46
66
|
docker-compose.yml
|
7
追記
test
CHANGED
File without changes
|
test
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=m
|
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
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -106,22 +106,128 @@
|
|
106
106
|
|
107
107
|
|
108
108
|
ターミナルに打ち込んだ時に得られる情報
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
|
110
|
+
localのmysql詳細
|
111
|
+
```ここに言語を入力
|
112
|
+
コード
|
113
|
+
masa@MasaakinoMacBook-Air portfolio % pwd
|
114
|
+
/Users/masa/Desktop/portfolio
|
115
|
+
|
116
|
+
masa@MasaakinoMacBook-Air portfolio % mysql -u hoge -p sample;
|
117
|
+
Enter password:
|
118
|
+
//『777』を入力
|
119
|
+
Welcome to the MySQL monitor. Commands end with ; or \g.
|
120
|
+
Your MySQL connection id is 27
|
121
|
+
Server version: 8.0.28 Homebrew
|
122
|
+
|
123
|
+
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
|
124
|
+
|
125
|
+
Oracle is a registered trademark of Oracle Corporation and/or its
|
126
|
+
affiliates. Other names may be trademarks of their respective
|
127
|
+
owners.
|
128
|
+
|
129
|
+
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
130
|
+
|
131
|
+
mysql> select user( );
|
132
|
+
+----------------+
|
133
|
+
| user( ) |
|
134
|
+
+----------------+
|
135
|
+
| hoge@localhost |
|
136
|
+
+----------------+
|
137
|
+
1 row in set (0.00 sec)
|
138
|
+
|
139
|
+
mysql> show databases;
|
140
|
+
+--------------------+
|
141
|
+
| Database |
|
142
|
+
+--------------------+
|
143
|
+
| information_schema |
|
144
|
+
| sample |
|
145
|
+
+--------------------+
|
146
|
+
2 rows in set (0.01 sec)
|
147
|
+
|
148
|
+
mysql> SELECT DATABASE();
|
149
|
+
+------------+
|
150
|
+
| DATABASE() |
|
151
|
+
+------------+
|
152
|
+
| sample |
|
153
|
+
+------------+
|
154
|
+
1 row in set (0.00 sec)
|
155
|
+
|
156
|
+
|
157
|
+
mysql> use sample;
|
158
|
+
Database changed
|
159
|
+
mysql> SELECT DATABASE();
|
160
|
+
+------------+
|
161
|
+
| DATABASE() |
|
162
|
+
+------------+
|
163
|
+
| sample |
|
164
|
+
+------------+
|
165
|
+
1 row in set (0.00 sec)
|
166
|
+
|
167
|
+
mysql> exit
|
168
|
+
Bye
|
169
|
+
|
170
|
+
masa@MasaakinoMacBook-Air portfolio % mysql -u root -p
|
171
|
+
Enter password:
|
172
|
+
//『secret』を入力
|
173
|
+
Welcome to the MySQL monitor. Commands end with ; or \g.
|
174
|
+
Your MySQL connection id is 30
|
175
|
+
Server version: 8.0.28 Homebrew
|
176
|
+
|
177
|
+
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
|
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
|
+
|
185
|
+
mysql>
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
実際のphp artisan migrateがうまく行かない部分の詳細
|
190
|
+
```ここに言語を入力
|
191
|
+
コード
|
192
|
+
masa@MasaakinoMacBook-Air portfolio % mysql.server restart
|
193
|
+
Shutting down MySQL
|
194
|
+
. SUCCESS!
|
195
|
+
Starting MySQL
|
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
|
113
216
|
/var/www/html
|
114
|
-
root@
|
217
|
+
root@8be8ddaa6767:/var/www/html# ls -a
|
115
|
-
|
218
|
+
. .editorconfig .env.testing .gitignore .styleci.yml app bootstrap composer.lock database package-lock.json phpunit.xml resources server.php tests webpack.mix.js
|
116
|
-
|
219
|
+
.. .env .gitattributes .phpunit.result.cache README.md artisan composer.json config node_modules package.json public routes storage vendor
|
220
|
+
|
117
|
-
root@
|
221
|
+
root@8be8ddaa6767:/var/www/html# php artisan config:cache
|
118
|
-
[1] 17
|
119
|
-
[2] 18
|
120
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
|
121
227
|
Application cache cleared!
|
122
|
-
|
123
|
-
|
124
|
-
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 = m
|
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')
|
125
231
|
|
126
232
|
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
|
127
233
|
665| // If an exception occurs when attempting to run a query, we'll format the error
|
@@ -139,142 +245,11 @@
|
|
139
245
|
1 PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known")
|
140
246
|
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
141
247
|
|
142
|
-
2 PDO::__construct("mysql:host=db;port=3306;dbname=m
|
248
|
+
2 PDO::__construct("mysql:host=db;port=3306;dbname=sample", "hoge", "777", [])
|
143
249
|
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
|
144
250
|
|
145
251
|
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@
|
252
|
+
root@8be8ddaa6767:/var/www/html#
|
149
|
-
|
253
|
+
|
150
|
-
masa@MasaakinoMacBook-Air docker-laravel-vue % pwd
|
151
|
-
/Users/masa/Desktop/portfolio
|
152
|
-
masa@MasaakinoMacBook-Air docker-laravel-vue % mysql -u root -p
|
153
|
-
Enter password:
|
154
|
-
Welcome to the MySQL monitor. Commands end with ; or \g.
|
155
|
-
Your MySQL connection id is 8
|
156
|
-
Server version: 8.0.28 Homebrew
|
157
|
-
|
158
|
-
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
|
159
|
-
|
160
|
-
Oracle is a registered trademark of Oracle Corporation and/or its
|
161
|
-
affiliates. Other names may be trademarks of their respective
|
162
|
-
owners.
|
163
|
-
|
164
|
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
165
|
-
|
166
|
-
mysql> show databases;
|
167
|
-
+--------------------+
|
168
|
-
| Database |
|
169
|
-
+--------------------+
|
170
|
-
| information_schema |
|
171
|
-
| mysql |
|
172
|
-
| performance_schema |
|
173
|
-
| SampleApp |
|
174
|
-
| sys |
|
175
|
-
| todo |
|
176
|
-
+--------------------+
|
177
|
-
6 rows in set (0.01 sec)
|
178
|
-
|
179
|
-
mysql> SELECT user, host, plugin FROM mysql.user;
|
180
|
-
+------------------+-----------+-----------------------+
|
181
|
-
| user | host | plugin |
|
182
|
-
+------------------+-----------+-----------------------+
|
183
|
-
| admin | localhost | caching_sha2_password |
|
184
|
-
| mysql.infoschema | localhost | caching_sha2_password |
|
185
|
-
| mysql.session | localhost | caching_sha2_password |
|
186
|
-
| mysql.sys | localhost | caching_sha2_password |
|
187
|
-
| root | localhost | mysql_native_password |
|
188
|
-
+------------------+-----------+-----------------------+
|
189
|
-
5 rows in set (0.00 sec)
|
190
|
-
|
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
|
-
|
195
|
-
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> show tables;
|
199
|
-
+------------------------------------------------------+
|
200
|
-
| Tables_in_mysql |
|
201
|
-
+------------------------------------------------------+
|
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
|
-
| slave_master_info |
|
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
|
-
+------------------------------------------------------+
|
240
|
-
37 rows in set (0.00 sec)
|
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
|
-
|
272
|
-
mysql> exit
|
273
|
-
Bye
|
274
|
-
masa@MasaakinoMacBook-Air docker-laravel-vue % mysql.server restart //このコマンドは毎回使用
|
275
|
-
Shutting down MySQL
|
276
|
-
. SUCCESS!
|
277
|
-
Starting MySQL
|
278
|
-
. SUCCESS!
|
279
|
-
```
|
254
|
+
```
|
280
|
-
|
255
|
+
|
5
追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
php artisan migrateがうまく行かない
|
1
|
+
php artisan migrateがうまく行かない
|
test
CHANGED
File without changes
|
4
追記
test
CHANGED
File without changes
|
test
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 //このコマンドは毎回使用
|
@@ -248,6 +278,3 @@
|
|
248
278
|
. SUCCESS!
|
249
279
|
```
|
250
280
|
|
251
|
-
参考文献
|
252
|
-
DB_HOSTURL=dbの部分について
|
253
|
-
https://yama-weblog.com/does-not-work-php-artisan-migrate-in-docker-environment/
|
3
追記
test
CHANGED
File without changes
|
test
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
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
-
エラー文中の
|
5
|
-
PDO::__construct("mysql:host=db;port=3306;dbname=mysql", "root", "secret", [])
|
6
|
-
の[ ]部分の意味がよくわからないのですがこれが原因?の可能性もあるかもしれないので現在進行形で調べて行きたいと思います。
|
7
4
|
|
8
5
|
|
9
6
|
バージョン
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
Macでlaravel,vue.js,docker(ローカルではdockerにnginxを使用)を使用してローカルでWEBアプリを制作しています。.envの設定がおかしいからだとは思いますが、dbとして使用しているローカルのmysqlに繋がらず、そのために$php artisan migrateがエラーとなって詰まってしまっています。どこの設定が間違っているためにmysqlに繋がらないのかを知りたいのですがよろしくお願いします。
|
2
|
+
|
3
|
+
・・追記・・
|
4
|
+
エラー文中の
|
5
|
+
PDO::__construct("mysql:host=db;port=3306;dbname=mysql", "root", "secret", [])
|
6
|
+
の[ ]部分の意味がよくわからないのですがこれが原因?の可能性もあるかもしれないので現在進行形で調べて行きたいと思います。
|
7
|
+
|
2
8
|
|
3
9
|
バージョン
|
4
10
|
php: 7.2.5
|