D
D
Denis Sokolov2021-07-18 18:32:12
Node.js
Denis Sokolov, 2021-07-18 18:32:12

How to connect MySQL database on hosting?

How to connect a database on the server.
Constantly writes an error: Error: connect ETIMEDOUT 94.241.44.78:3306

const connection = mysql.createConnection({
    host: 'localhost',
    user: 'test',
    password: 'test',
    port: 3306
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vozvratiKota, 2021-07-20
@vozvratiKota

I'm certainly not an expert, but ... there was no need to specify the database? type database: "test",
and the port, if nothing was specially configured, can be omitted. works for me like this:
const connection = mysql.createConnection({
host: "localhost",
user: "root",
database: "forum",
password: "12345"
}).promise();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question