Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //using the root user. Probably bad practice. You should create a user with a password.
- //make sure the database you are using exists, otherwise create it using the sql terminal.
- const mysql = require('mysql');
- const connection = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: '',
- database: 'myLibrary'
- });
- connection.connect(function (err) {
- if (err) {
- console.error('error connecting: ' + err.stack);
- return;
- }
- console.log('connected as id ' + connection.threadId);
- });
Add Comment
Please, Sign In to add comment