errorError: getaddrinfo ENOTFOUND - mysql

前端 未结 5 1475
温柔的废话
温柔的废话 2021-01-18 01:17

I\'m running a server on c9.io using Node.js and trying to connect to Mysql I guess I get this error:

Error: getaddrinfo ENOTFOUND

5条回答
  •  無奈伤痛
    2021-01-18 01:34

    I almost spend two hours to understand what is the problem with the mysql database. I am using Windows cmd. I tried multiple ways e.g

    1. npm install mysql2
    2. Changing localhost to 127.0.0.1
    3. Refreshing node

    so in order to resolve this issue

    [Error: getaddrinfo ENOTFOUND 127.0.0.1:3306]
    

    I open XAMPP and start the MySQL database then manually check the credentials and works fine for me.

    var mysql = require('mysql');
    
    var connection = mysql.createConnection({
      host    : 'localhost',
      user    : 'test',
      password: 'test123',
    }); 
    

提交回复
热议问题