Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
create pool for MySQL

hello I want to create a pool for MySQL but I got an error

Cannot read property 'createPool' of undefined notice,

I installed MySQL for my project

require("dotenv").config();

const { mysql } = require("mysql");

const isProduction = process.env.NODE_ENV === "production";

const connectionString = `mysql://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_DATABASE}`;

const pool = mysql.createPool({
  connectionString: isProduction ? 
  process.env.DATABASE_URL : connectionString,
  ssl: isProduction
});

module.exports = { pool };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The npm package mysql doesn't export an object containing a property mysql. You either have to import the whole object

const mysql = require("mysql");

or only the function

const { createPool } = require("mysql");

and use it like

const pool = createPool({
  connectionString: isProduction ? 
  process.env.DATABASE_URL : connectionString,
  ssl: isProduction
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!