'use strict';
let mysql = require('mysql');
let connection = mysql.createConnection({
host : 'localhost',
user : 'nobu2',
password : '1234',
port : 3306,
database: 'test'
});
connection.connect();
connection.query('SELECT * from dual;', (err, rows, fields) => {
if (err) throw err;
console.log(rows);
});
connection.end();
エラーがでた
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'nobu2'@'localhost' (using password: YES)
権限をつけよう
GRANT ALL ON *.* TO nobu2@'localhost' IDENTIFIED BY '1234' WITH GRANT OPTION;
node 実行
$ node hello.js
aaaa
matsushitanobuhitonoMacBook-Air:sample matsushitanobuhito$