- The first thing we need to do is to create a database, which we will name as blog, and use it:
CREATE DATABASE blog; USE blog;
- Now that we have our database ready let's work on the MySQL implementation with Node.js. There are many ways to use MySQL with Node, but for this recipe, we will use a package called Sequelize, which is a robust ORM for MySQL and other databases such as SQLite, Postgres, and MsSQL.
- The first thing we need to do is to create a config file to add our database configuration (host, database, user, password, etc). To do this, you need to create a file called config/index.js:
export default { db: { dialect: 'mysql', // 'mysql'|'sqlite'|'postgres'|'mssql' host: 'localhost', // Your host, by default ...