IT 全栈开发

node mysql enconnrefused 127.0.0

2021-11-21  本文已影响0人  醋留香

原来的连接方式:

 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();
上一篇 下一篇

猜你喜欢

热点阅读