美文网首页IT 全栈开发
node mysql enconnrefused 127.0.0

node mysql enconnrefused 127.0.0

作者: 醋留香 | 来源:发表于2021-11-21 16:27 被阅读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();
    

    相关文章

      网友评论

        本文标题:node mysql enconnrefused 127.0.0

        本文链接:https://www.haomeiwen.com/subject/cpcmtrtx.html