原来的连接方式:
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '123456',
database: 'xxx'
});
connection.connect();
修改之后的代码:
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '123456',
database: 'xxx',
socketPath: '/tmp/mysql.sock'
});
connection.connect();
网友评论