lotteve
By:
lotteve

Node js cannot allow to access MySQL on digital ocean

November 8, 2017 116 views
DigitalOcean MySQL Node.js

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 0.0.0.0

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

1 Answer

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:

mysql>GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'%'
IDENTIFIED BY 'newpassword';

Then refresh the privileges with:

mysql>FLUSH PRIVILEGES;

Source: Similar Question

Replace user and newpassword with what your node app uses.

Have another answer? Share your knowledge.