I've tried to implement this code and terminal throws error something like this stucked in it As I've applied this code but it throws the error "Access denied for user ''@'localhost' to database 'mydb'"
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "myusername",
password: "mypassword"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
/*Create a database named "mydb":*/
con.query("CREATE DATABASE mydb", function (err, result) {
if (err) throw err;
console.log("Database created");
});
});
mysqlfrom terminal.connectwithout thecon.query?con.query()outside