Node js cannot allow to access MySQL on digital ocean

Posted November 8, 2017 3.4k views

Got the error like this

ERHOSTNOT_PRIVILEGED: Host …xxx… is not allowed to connect to this my sql server

in the bind address already set to

how to allow my node js to access to my sql server

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Try entering the mysql environment on the droplet via mysql -u root -p (mysql root password is usually in /root/.mysqlpassword or /root/.digitaloceanpassword).

Then grant privileges to all hosts accessing the database with:

ON database.*
TO 'user'@'%'
IDENTIFIED BY 'newpassword';

Then refresh the privileges with:


Source: Similar Question

Replace user and newpassword with what your node app uses.

Hi @lotteve,

The below documentation can guide you with allowing remote access to the MySQL database :


by Mark Drake
Many websites and applications start off with their web server and database backend hosted on the same machine. With time, though, a setup like this can become cumbersome and difficult to scale. A common solution is to separate these functions by setting up a remote database, allowing the server...