Use node JS database module MySQL
, connection database query error
Error: connect ECONNREFUSED ::1:3306
reason
I annotated the mapping relationship of /ECT/hosts
# 127.0.0.1 localhost
The original configuration used localhost
, so the database could not be connected suddenly
{
host: 'localhost',
user: 'root',
password: '123456',
database: 'data',
};
Treatment method
Method 1:
Change the mapping relationship of /ECT/hosts
# 127.0.0.1 localhost
127.0.0.1 localhost
Method 2:
You can use 127.0.0.1
instead
{
// host: 'localhost',
host: '127.0.0.1',
user: 'root',
password: '123456',
database: 'data',
};