Guest User

Untitled

a guest
Jun 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. //using the root user. Probably bad practice. You should create a user with a password.
  2. //make sure the database you are using exists, otherwise create it using the sql terminal.
  3.  
  4. const mysql = require('mysql');
  5. const connection = mysql.createConnection({
  6. host: 'localhost',
  7. user: 'root',
  8. password: '',
  9. database: 'myLibrary'
  10. });
  11.  
  12. connection.connect(function (err) {
  13. if (err) {
  14. console.error('error connecting: ' + err.stack);
  15. return;
  16. }
  17.  
  18. console.log('connected as id ' + connection.threadId);
  19. });
Add Comment
Please, Sign In to add comment