Reputation: 109
I'm experiencing an issue when trying to connect to a MySQL database with Node.JS in my React Native application.
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
port: 8889,
database: "blabla"
});
con.connect(function(err) {
if (err) console.log(err);
});
I can access to phpmyadmin without any problem (same user and password) but when I execute the JS file the terminal seems to load but stay stuck like this:
I don't think that there is a link with React but I really have no idea about it.
Thanks in advance for your help
Upvotes: 1
Views: 836
Reputation: 2041
According to the mysql docs: https://www.npmjs.com/package/mysql you need to add con.end();
after you are finished with the connection.
Upvotes: 2
Reputation: 109
I just understood that I didn't exit the script, but it's working (sorry).
The line to end the script for Node.js beginners like me:
process.exit()
Upvotes: 0