I have the next code in a js file:
var mysql = require(\'mysql\');
var TEST_DATABASE = \'nodejs_mysql_test\';
var TEST_TABLE = \'test\';
var
I know two ways to solve it:
In mysql.conf
, comment skip-networking
.
Try to set the socket like this:
var client = mysql.createClient({
user: uuuu,
password: pppp,
host: '127.0.0.1',
port: '3306',
_socket: '/var/run/mysqld/mysqld.sock',});
I got this error when MySQL Server was not running.
I changed my configuration via Initialize Database in MySQL.PrefPane, the System Preferences tool for MySQL on OS X - to Use Legacy Password Encryption - to fix ER_NOT_SUPPORTED_AUTH_MODE. This config change stopped MySQL Server and then I got ECONNREFUSED when I tried to connect to MySQL from node.js.
Fixed by restarting MySQL Server from the MySQL System Preferences tool.
Try to fix your defined port in mysql and your Node.js script. You can define the mysqld port in the *.cnf file inside the mysql directory, and you can define that port when you connect to MySQL in your Node.js script.
Something like this in the cnf file
port = 3360