0

I had completed my website (React+node+express+mysql). and i want to host my whole website in linux server. i successfully created the database in mysql but i encountered some error.

I tried this solution already. it didn't work for me

My error is

Error connecting to database: Error: connect ECONNREFUSED 185.181.11.232:3306

I created my database like this

const connection = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "***",
    database: "attendance"
});

connection.connect(function (error) {
    if (error) {
        console.error('Error connecting to database: ' + error.stack);
        return;
    }
    console.log('Connected to database with ID ' + connection.threadId);
});

Please give me some suggestion how can i correct this

I am expecting to output like this Connected to database with ID

  • Is the server yours or a shared one? – RiggsFolly Mar 27 '23 at 17:30
  • If the new server is a shared server they are not going to let you use the MySQL `root` account. There will be something in your panel telling you how to create a MySQL user or the one they create for you, you will have to change the code to use that – RiggsFolly Mar 27 '23 at 17:31
  • @RiggsFolly it does not even get to authenticating with a mysql user, connection refused means that the code cannot even reach mysql. – Shadow Mar 27 '23 at 17:34
  • Usually `localhost` connects using a Unix-domain socket, not a network socket. – Barmar Mar 27 '23 at 17:35
  • actually in my cpanel nothing is given about the database. so i am really confused. – user21503661 Mar 27 '23 at 17:46

0 Answers0