0
Q:

node js mysql create table

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
  
  con.query(`CREATE TABLE customers (
    name VARCHAR(255),
    address VARCHAR(255)
  )`, (err, result) => {
    if (err) throw err;
    
    console.log("Table created!");
  });
});
 
0

New to Communities?

Join the community