質問編集履歴
2
hghgログイン時のjs追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -346,6 +346,78 @@
|
|
346
346
|
|
347
347
|
|
348
348
|
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
```
|
356
|
+
|
357
|
+
```hghgjs
|
358
|
+
|
359
|
+
const express = require('express');
|
360
|
+
|
361
|
+
const mysql = require('mysql');
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
const app = express();
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
const connection = mysql.createConnection({
|
370
|
+
|
371
|
+
host: 'localhost',
|
372
|
+
|
373
|
+
user: 'hghg',
|
374
|
+
|
375
|
+
password: '[1111]',
|
376
|
+
|
377
|
+
database: 'list_app'
|
378
|
+
|
379
|
+
});
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
connection.connect((err) => {
|
384
|
+
|
385
|
+
if (err) {
|
386
|
+
|
387
|
+
console.log('error connecting: ' + err.stack);
|
388
|
+
|
389
|
+
return;
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
console.log('success');
|
394
|
+
|
395
|
+
});
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
app.get('/', (req, res) => {
|
400
|
+
|
401
|
+
connection.query(
|
402
|
+
|
403
|
+
'SELECT * FROM users',
|
404
|
+
|
405
|
+
(error, results) => {
|
406
|
+
|
407
|
+
console.log(results);
|
408
|
+
|
409
|
+
res.render('hello.ejs');
|
410
|
+
|
411
|
+
}
|
412
|
+
|
413
|
+
);
|
414
|
+
|
415
|
+
});
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
app.listen(3000);
|
420
|
+
|
349
421
|
```
|
350
422
|
|
351
423
|
### 試したこと
|
1
root→hghgユーザー変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -220,7 +220,133 @@
|
|
220
220
|
|
221
221
|
```
|
222
222
|
|
223
|
-
|
223
|
+
```mysqlhghg
|
224
|
+
|
225
|
+
mysql> create user 'hghg'@'localhost' identified by '1111';
|
226
|
+
|
227
|
+
Query OK, 0 rows affected (0.01 sec)
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
mysql> select user,host from mysql.user;
|
232
|
+
|
233
|
+
+------------------+-----------+
|
234
|
+
|
235
|
+
| user | host |
|
236
|
+
|
237
|
+
+------------------+-----------+
|
238
|
+
|
239
|
+
| hghg | localhost |
|
240
|
+
|
241
|
+
| mysql.infoschema | localhost |
|
242
|
+
|
243
|
+
| mysql.session | localhost |
|
244
|
+
|
245
|
+
| mysql.sys | localhost |
|
246
|
+
|
247
|
+
| root | localhost |
|
248
|
+
|
249
|
+
+------------------+-----------+
|
250
|
+
|
251
|
+
5 rows in set (0.00 sec)
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
mysql> grant all on list_app.*to'hghg'@localhost;
|
256
|
+
|
257
|
+
Query OK, 0 rows affected (0.01 sec)
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
mysql> quit;
|
262
|
+
|
263
|
+
Bye
|
264
|
+
|
265
|
+
fukazawaikkinoMacBook-Air:list-app fukazawaikki$ mysql --user=hghg --password
|
266
|
+
|
267
|
+
Enter password:
|
268
|
+
|
269
|
+
Welcome to the MySQL monitor. Commands end with ; or \g.
|
270
|
+
|
271
|
+
Your MySQL connection id is 43
|
272
|
+
|
273
|
+
Server version: 8.0.19 Homebrew
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
Oracle is a registered trademark of Oracle Corporation and/or its
|
282
|
+
|
283
|
+
affiliates. Other names may be trademarks of their respective
|
284
|
+
|
285
|
+
owners.
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
mysql> exit;
|
294
|
+
|
295
|
+
Bye
|
296
|
+
|
297
|
+
fukazawaikkinoMacBook-Air:list-app fukazawaikki$ brew services start mysql@5.7
|
298
|
+
|
299
|
+
Service `mysql@5.7` already started, use `brew services restart mysql@5.7` to restart.
|
300
|
+
|
301
|
+
fukazawaikkinoMacBook-Air:list-app fukazawaikki$ node app.js
|
302
|
+
|
303
|
+
error connecting: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
|
304
|
+
|
305
|
+
at Handshake.Sequence._packetToError (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
|
306
|
+
|
307
|
+
at Handshake.ErrorPacket (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
|
308
|
+
|
309
|
+
at Protocol._parsePacket (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Protocol.js:291:23)
|
310
|
+
|
311
|
+
at Parser._parsePacket (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Parser.js:433:10)
|
312
|
+
|
313
|
+
at Parser.write (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Parser.js:43:10)
|
314
|
+
|
315
|
+
at Protocol.write (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Protocol.js:38:16)
|
316
|
+
|
317
|
+
at Socket.<anonymous> (/Users/fukazawaikki/list-app/node_modules/mysql/lib/Connection.js:88:28)
|
318
|
+
|
319
|
+
at Socket.<anonymous> (/Users/fukazawaikki/list-app/node_modules/mysql/lib/Connection.js:526:10)
|
320
|
+
|
321
|
+
at Socket.emit (events.js:315:20)
|
322
|
+
|
323
|
+
at addChunk (_stream_readable.js:295:12)
|
324
|
+
|
325
|
+
--------------------
|
326
|
+
|
327
|
+
at Protocol._enqueue (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
|
328
|
+
|
329
|
+
at Protocol.handshake (/Users/fukazawaikki/list-app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
|
330
|
+
|
331
|
+
at Connection.connect (/Users/fukazawaikki/list-app/node_modules/mysql/lib/Connection.js:116:18)
|
332
|
+
|
333
|
+
at Object.<anonymous> (/Users/fukazawaikki/list-app/app.js:13:12)
|
334
|
+
|
335
|
+
at Module._compile (internal/modules/cjs/loader.js:1138:30)
|
336
|
+
|
337
|
+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
|
338
|
+
|
339
|
+
at Module.load (internal/modules/cjs/loader.js:986:32)
|
340
|
+
|
341
|
+
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
|
342
|
+
|
343
|
+
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
|
344
|
+
|
345
|
+
at internal/main/run_main_module.js:17:47
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
```
|
224
350
|
|
225
351
|
### 試したこと
|
226
352
|
|