teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

2022/01/01 03:33

投稿

tiffany_rom_24
tiffany_rom_24

スコア28

title CHANGED
File without changes
body CHANGED
@@ -34,7 +34,7 @@
34
34
  ①パスワードを空欄にしましたが、解決にはなりませんでした。
35
35
 
36
36
  ②以下の記事に書いてあることを試しましたが、バージョンが違うからか機能しませんでした。
37
- https://at284km.hatenablog.com/entry/2015/07/11/065931
37
+ [リンク内容](http://at284km.hatenablog.com/entry/2015/07/11/065931)
38
38
 
39
39
  ③```mysql -u root -p```を実行してパスワードを入力すればログインはできています。
40
40
 

2

疑問の追記

2022/01/01 03:33

投稿

tiffany_rom_24
tiffany_rom_24

スコア28

title CHANGED
File without changes
body CHANGED
@@ -42,4 +42,6 @@
42
42
  ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
43
43
  のエラーが表示されます。
44
44
 
45
+ jsファイル内で```use database xxx;```を実行する必要があるのでしょうか。。。
46
+
45
47
  どなたかパスワード入力不要にする方法を教えていただきたいです。

1

ソースコードの掲載

2021/12/31 06:04

投稿

tiffany_rom_24
tiffany_rom_24

スコア28

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,31 @@
5
5
  mysql Ver 8.0.27 for Win64 on x86_64 (MySQL Community Server - GPL)
6
6
  ターミナル windowsコマンドプロンプト
7
7
  node 14.18.1
8
+ express ^4.17.2
8
9
 
10
+ ##ソースコード
11
+
12
+ jsファイルはこのようになっています。expressとmysqlはnpm install済みです。
13
+
14
+ ```
15
+ const express = require('express')
16
+ const mysql = require('mysql')
17
+
18
+ const connection = mysql.createConnection({
19
+ host: 'localhost',
20
+ port: 3000,
21
+ user: 'root',
22
+ password: 'password',
23
+ database: 'mydb'
24
+ })
25
+
26
+ connection.connect()
27
+ connection.query('select * from files', (e, result) => {
28
+ console.log(result);
29
+ })
30
+ 省略
31
+ ```
32
+
9
33
  ##やったこと
10
34
  ①パスワードを空欄にしましたが、解決にはなりませんでした。
11
35