mysql create pool 1

mysql create pool

var mysql = require('mysql');

var pool      =    mysql.createPool({
    connectionLimit : 10,
    host     : '127.0.0.1',
    user     : '_DB_USER_',
    password : '_DB_PASSWORD_',
    database : '_DB_NAME_',
    debug    :  false
});    
module.exports = pool;

Here is what the above code is Doing:
1. We are creating a pool of connections to the database.
2. We are setting the connection limit to 10.
3. We are setting the host to localhost.
4. We are setting the user to _DB_USER_.
5. We are setting the password to _DB_PASSWORD_.
6. We are setting the database to _DB_NAME_.
7. We are setting the debug to false.
8. We are exporting the pool.

Now, let’s create a file called db.js and add the following code to it:

Similar Posts