I'm new to Node and learning how to query data from MySQL. I get the following error:
err { [Error: ER_BAD_DB_ERROR: Unknown database '201803028'] code: 'ER_BAD_DB_ERROR', errno: 1049, sqlMessage: 'Unknown database \'201803028\'', sqlState: '42000', fatal: true }
here is my code
const mysql = require('mysql');
var db = mysql.createConnection({ host:'localhost', user:'root', password:'123456', database:'201803028'});
db.query('SELECT * FROM
user-table
;',(err,data)=>{ if(err){ console.log('err',err); }else{ console.log('success',data); } })
Could anyone tell me what's the matter with my coding?
Thank you very much!
201803028
does not exist. You should create it before you connect to it. – Csaba201803028
correct? It might be20180328
– Adder