0
Code to establish connection to the database:
const Sequelize = require('sequelize')
// Conexão com o banco de dados MySQL
const sequelize = new Sequelize('postagens', 'root', 'mafikgod123@', {
host: "localhost",
dialect: "mysql"
})
module.exports = {
Sequelize: Sequelize,
sequelize: sequelize
}
Model post
:
const db = require('./db')
const Post = db.sequelize.define('postagens', {
titulo: {
type: db.Sequelize.STRING
},
conteudo: {
type: db.Sequelize.TEXT
}
})
Post.sync({force: true})
Error:
Unhandled rejection SequelizeConnectionError: Client does not support authentication protocol requested by server; consider upgrading MySQL client at Promise.tap.then.catch.err (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:133:19) at tryCatcher (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\promise.js:517:31) at Promise._settlePromise (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\promise.js:574:18) at Promise._settlePromise0 (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\promise.js:619:10) at Promise._settlePromises (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\promise.js:695:18) at _drainQueueStep (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues (C:\Users\wesley\Desktop\CURSO-NODE\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5)