All Questions

Tagged with
Filter by
Sorted by
Tagged with
773 votes
35 answers
1.1m views

MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

I can't make a simple connection to the server for some reason. I install the newest MySQL Community 8.0 database along with Node.JS with default settings. This is my node.js code var mysql = ...
Pig 's user avatar
  • 7,835
384 votes
9 answers
318k views

MySQL with Node.js

I've just started getting into Node.js. I come from a PHP background, so I'm fairly used to using MySQL for all my database needs. How can I use MySQL with Node.js?
crawf's user avatar
  • 9,548
340 votes
4 answers
231k views

Which ORM should I use for Node.js and MySQL? [closed]

I'm rewriting a project to use Node.js. I'd like to keep using MySQL as the DB (even though I don't mind rewriting the schema). I'm looking for a simple-to-use, reasonable-performance ORM, which ...
Near Privman's user avatar
  • 3,740
186 votes
21 answers
509k views

How to update a record using sequelize for node?

I'm creating a RESTful API with NodeJS, express, express-resource, and Sequelize that is used to manage datasets stored in a MySQL database. I'm trying to figure out how to properly update a record ...
a_arias's user avatar
  • 3,066
180 votes
15 answers
236k views

How do I do a bulk insert in mySQL using node.js

How would one do a bulk insert into mySQL if using something like https://github.com/felixge/node-mysql
crickeys's user avatar
  • 3,095
170 votes
5 answers
328k views

How to make join queries using Sequelize on Node.js

I am using sequelize ORM; everything is great and clean, but I had a problem when I use it with join queries. I have two models: users and posts. var User = db.seq.define('User',{ username: { ...
Jose Sosa's user avatar
  • 2,207
143 votes
5 answers
123k views

How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.
user avatar
133 votes
11 answers
254k views

How to auto generate migrations with Sequelize CLI from Sequelize models?

I have a set of Sequelize models. I want to use migrations, not DB Sync. Sequelize CLI seems to be able to do this, according to this article: "When you use the CLI for the model generation, you will ...
Michael Schmidt's user avatar
122 votes
6 answers
185k views

nodejs mysql Error: Connection lost The server closed the connection

when I use node mysql, an error is appear between 12:00 to 2:00 that the TCP connection is shutdown by the server. This is the full message: Error: Connection lost: The server closed the connection. ...
jackieLin's user avatar
  • 1,277
114 votes
5 answers
131k views

sequelize table without column 'id'

I have the following sequelize definition of a table: AcademyModule = sequelize.define('academy_module', { academy_id: DataTypes.INTEGER, module_id: DataTypes.INTEGER, ...
Marc Rasmussen's user avatar
112 votes
5 answers
208k views

Preventing SQL injection in Node.js

Is it possible to prevent SQL injections in Node.js (preferably with a module) in the same way that PHP had Prepared Statements that protected against them. If so, how? If not, what are some examples ...
funseiki's user avatar
  • 9,307
105 votes
8 answers
190k views

node.js + mysql connection pooling

I'm trying to figure out how to structure my application to use MySQL most efficent way. I'm using node-mysql module. Other threads here suggested to use connection pooling so i set up a little module ...
kasztelan's user avatar
  • 1,761
103 votes
17 answers
202k views

How to access a RowDataPacket object

I'm currently developing a desktop application with Node-webkit. During that process I need to get some data from a local MySQL-database. The querying works fine, but I can't figure out how to access ...
paK0's user avatar
  • 2,548
91 votes
4 answers
142k views

node-mysql multiple statements in one query

I'm using nodejs 10.26 + express 3.5 + node-mysql 2.1.1 + MySQL-Server Version: 5.6.16. I got 4 DELETE's and want only 1 Database Request, so i connected the DELETE commands with a ";"... but it ...
L.rp's user avatar
  • 933
90 votes
4 answers
128k views

Specifying specific fields with Sequelize (NodeJS) instead of *

Alright so I have a project in NodeJS where I'm utilizing Sequelize for a MySQL ORM. The thing works fantastically however I'm trying to figure out if there is a way to specify what fields are being ...
Aric's user avatar
  • 1,357
86 votes
13 answers
177k views

ER_NOT_SUPPORTED_AUTH_MODE - MySQL server

Failed at Connecting Node.js Server to MySQL-Database         I had MariaDB" installed on a "Node.js Server", but decided that I wanted to use a SQL Database instead. I uninstalled, ...
João Gouveia's user avatar
82 votes
3 answers
126k views

Retrieve last inserted id with Mysql

Good day, I am willing to retrieve the id value of a freshly inserted row in Mysql. I know there is mysqli_insert_id function, but: I can't specify the table Maybe there would be a risk of retrieving ...
lopata's user avatar
  • 1,345
77 votes
10 answers
163k views

Create or Update Sequelize

I'm using Sequelize in my Nodejs project and I found a problem that I'm having a hard time to solve. Basically I have a cron that gets an array of objects from a server than inserts it on my database ...
Thiago Miranda de Oliveira's user avatar
65 votes
1 answer
3k views

Express-mysql-session preventing passport deserializeUser from running

I have an app using passport.js to log in users through facebook, and am attempting to use express-mysql-session to persist their login states. If I don't include the express-mysql-session code, the ...
user2796352's user avatar
64 votes
3 answers
96k views

Sequelize: Destroy/Delete all records in the table

I am using Mocha for Unit tests. When testing begins, I would like to delete all the previous records in a table. What I have tried: db.User.destroy({ force: true }).then(() => { }).then(() =&...
user1107173's user avatar
  • 10.5k
63 votes
7 answers
126k views

How to provide a mysql database connection in single file in nodejs

I need to provide the mysql connection for modules. I have a code like this. var express = require('express'), app = express(), server = require('http').createServer(app); var mysql = require('...
user3836476's user avatar
  • 1,075
63 votes
6 answers
95k views

What is the difference between MySQL & MySQL2 considering NodeJS

I have read the following: What the difference between mysql and mysql2 gem So far I have only used MongoDB with NodeJS and I want to be able to learn MySQL for any of my relational database needs. ...
Eric Bishard's user avatar
  • 5,261
62 votes
35 answers
249k views

NodeJS/mySQL - ER_ACCESS_DENIED_ERROR Access denied for user 'root'@'localhost' (using password: YES)

I am attempting to connect to mySQL through a NodeJS file, but I receive the following error: { Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES) at ...
mwelk11's user avatar
  • 683
61 votes
5 answers
47k views

my nodejs script is not exiting on its own after successful execution

I have written a script to update my db table after reading data from db tables and solr. I am using asyn.waterfall module. The problem is that the script is not getting exited after successful ...
Vickrant's user avatar
  • 1,273
59 votes
5 answers
46k views

What MySQL drivers are available for node.js? [closed]

Is there a Node.JS Driver for MySQL that is commonly used other than node-mysql? (It seems like there is not much activity with node.js database drivers. Is there a reason for this or is it just ...
Brad Barrows's user avatar
  • 1,673
56 votes
2 answers
108k views

Auto increment id with sequelize in MySQL

I have the following model in NodeJS with sequelize and a MySQL database: var Sequelize = require('sequelize'); var User = sequelize.define('user', { id: { type: Sequelize....
Genzotto's user avatar
  • 1,974
50 votes
7 answers
93k views

How to insert moment JS time into MySQL

//In Node/JS myDate = moment(data.myTime.format('YYYY/MM/DD HH:MM:SS')).toISOString(); //myDate shows '2014-09-24T04:09:00.000Z' Insert INTO (dateColumn..) Values(myDate)... This is the error I get ...
user1529412's user avatar
  • 3,636
50 votes
5 answers
96k views

Counting associated entries with Sequelize

I have two tables, locations and sensors. Each entry in sensors has a foreign key pointing to locations. Using Sequelize, how do I get all entries from locations and total count of entries in sensors ...
MikkoP's user avatar
  • 5,032
49 votes
6 answers
36k views

How do you mock MySQL (without an ORM) in Node.js?

I'm using Node.js with felixge's node-mysql client. I am not using an ORM. I'm testing with Vows and want to be able to mock my database, possibly using Sinon. Since I don't really have a DAL per se (...
Josh Smith's user avatar
  • 14.9k
48 votes
30 answers
163k views

Error: secretOrPrivateKey must have a value

I am using jwt to create token, but when i login via postman I get the error "Error: secretOrPrivateKey must have a value" from my console. I have attached my login code. Please anyone who can help me ...
mchomvu's user avatar
  • 687
48 votes
6 answers
90k views

Sequelize limit and offset incorrect placement in query

I am using sequelize in nodeJs and I have this code: Time_Sheet_Details.findAll({ include: [ { model: timesheetNotesSubcon, required: false, attributes:["note",&...
Yassi's user avatar
  • 2,479
47 votes
5 answers
121k views

Sequelize.js foreign key

When using Sequelize.js, the following code doesn't add any foreign key on tables. var MainDashboard = sequelize.define('main_dashboard', { title: Sequelize.STRING }, { freezeTableName: true }) ...
swampcypress's user avatar
46 votes
13 answers
156k views

node.js async/await using with MySQL

I need to get all results synchronized and append to a string with async/await keywords like c#. I am new to node.js and I can not adapt this new syntax to my code. var string1 = ''; var ...
Burc Hasergin's user avatar
45 votes
3 answers
47k views

Node.js MySQL Needing Persistent Connection

I need a persistent MySQL connection for my Node web app. The problem is that this happens about a few times a day: Error: Connection lost: The server closed the connection. at Protocol.end (/var/www/...
apscience's user avatar
  • 7,153
45 votes
4 answers
69k views

Sequelize select * where attribute is NOT x

looking at the docs you can use model.findAll({where: {attribute: x}}). However, I want to select all attributes that are simply NOT x. I was looking into a regular expression here but that ...
joemillervi's user avatar
  • 1,037
45 votes
6 answers
105k views

sequelize.js TIMESTAMP not DATETIME

In my node.js app I have several models in which I want to define TIMESTAMP type columns, including the default timestamps created_at and updated_at. According to sequelize.js' documentation, there ...
ılǝ's user avatar
  • 3,470
42 votes
6 answers
47k views

using an enviroment variable for local sequelize configuration

I'm looking to use an environment variable inside of the config.json file of my project using sequelize. I'm using dotenv to set environment variables locally. My config.json file looks like this { ...
ceckenrode's user avatar
  • 4,613
42 votes
7 answers
82k views

Error: Handshake inactivity timeout in Node.js MYSQL module

I'm using node-mysql and most of the queries. Working. some queries not working. I tried every version of Node (from 0.5...) until (5.6.0), I also tried (4.0) and (4.1), Nothing helps. I tried to ...
Aminadav Glickshtein's user avatar
41 votes
6 answers
30k views

Node MySQL escape LIKE statement

How do escape a MySQL LIKE statement in node-mysql? Something along the lines of "SELECT * FROM card WHERE name LIKE '%" + connection.escape(req.body.search) + "%'" Results in 'SELECT * FROM card ...
dtsn's user avatar
  • 1,107
40 votes
21 answers
230k views

Node.js MySQL - Error: connect ECONNREFUSED

I use Node.js server side. I tried my code on localhost and everything works fine. I bought a server and installed Apache and node.js on it and test my web application there. I correctly changed the ...
Nico's user avatar
  • 699
40 votes
9 answers
110k views

Use promise to process MySQL return value in node.js

I have a python background and is currently migrating to node.js. I have problem adjusting to node.js due to its asynchronous nature. For example, I am trying to return a value from a MySQL function. ...
guagay_wk's user avatar
  • 27.3k
40 votes
7 answers
89k views

Sequelize bulkCreate() returns NULL value for primary key

I am writing rest using node, sequelize as ORM for mySQL. I am using bulkCreate function to create record in bulk. But in response it is returning null for primary key value. Model sequelize.define('...
Sunil Sharma's user avatar
  • 1,315
39 votes
9 answers
42k views

sequelize.js - You need to install mysql package manually

After installing node.js and sequelize.js, and running a basic test, the message "You need to install mysql package manually" is displayed. I've tried searching the web and Stackoverflow for the ...
thaspius's user avatar
  • 1,136
39 votes
3 answers
46k views

Error: Most middleware (like json) is no longer bundled with Express and must be installed separately. Please see

i move my source window to ubuntu : Error: Most middleware (like json) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware. ...
incleaf's user avatar
  • 1,935
39 votes
4 answers
63k views

Sequelize update with association

In sequelize it's possible to create a row and all its associations in one go like this: return Product.create({ title: 'Chair', User: { first_name: 'Mick', last_name: 'Broadstone' } }, {...
Jacob's user avatar
  • 994
38 votes
1 answer
28k views

Does Knex.js prevent sql injection?

I'm using a MySql database and was trying to find a MySQL alternative to tedious.js (a SQL server parameterised query builder).I'm using Node.js for my backend. I read that the .raw() command from ...
Harsh Saudagar's user avatar
38 votes
6 answers
49k views

Sequelize: Using Multiple Databases

Do I need to create multiple instances of Sequelize if I want to use two databases? That is, two databases on the same machine. If not, what's the proper way to do this? It seems like overkill to ...
dougBTV's user avatar
  • 1,893
38 votes
4 answers
132k views

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message lis teners added. Use emitter.setMaxListeners() to increase limit

I know this might flag as a duplicate solution but the solution on stack overflow is not working for me. Problem (node:5716) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ...
Nane's user avatar
  • 803
37 votes
16 answers
124k views

Cannot find module `mysql` node.js

i am a newbie to nodejs. To connect mysql, i installed mysql on node using the command, npm install mysql I didn't get any error while installing. Then i tried executing the following code, var ...
Stranger's user avatar
  • 10.5k
36 votes
2 answers
104k views

When to close MySQL connection using node-mysql?

Currently using: https://github.com/felixge/node-mysql I have the following code: var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', ...
ninjaneer's user avatar
  • 6,991

1
2 3 4 5
239