0

I'm starting at Node.js and i'm trying to make a simple connection with Sequelize based on its documentation (http://docs.sequelizejs.com/manual/installation/getting-started.html#installation). Here my db.js file :

const Sequelize = require('sequelize')

const db = new Sequelize('chat','root','root',{
    host: 'localhost',
    port: 3306,
    dialect: 'mysql'

});

db
  .authenticate()
  .then(() => {
    console.log('Connection has been established successfully.');
  })
  .catch(err => {
    console.error('Unable to connect to the database:', err);
  });

When executing this code, I have no success nor error message, just a message indicating 'String base operators deprecated' but nothing important i think.

I tried changing localhost to 127.0.0.1, remove port number and multiples thread but i'm stucked here...

1
  • Your code is correct. Commented Oct 25, 2017 at 19:45

1 Answer 1

1

Tested your code and all seemed to work fine, it connected successfully to the database instance I have running.
You might want to ensure mysql2 package is installed. Also check that the database chat has been created in MySQL workbench, and ensure the password is correct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.