Create a Database on DigitalOcean and connect to it externally (not on the same datacenter)

I’ve an instance server running (Scheduled) a scrapy application on another cloud service, also have another instance on DigitalOcean running the user interface (Flask Application to be precises) with database configured, How can i connect database on Digital Ocean to the Scrapy application running on another cloud server?

Note: The main reason is to allow the data scrap by the scrapy to be inserted into the database on digital ocean, please how can i achieve this. Already have mysql database install with phpmyadmin on DigitalOcean


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

By default MySQL does not allow remote connections and does not include a user account with permissions to reach the database from the outside. This can be adjusted fairly easily.

1.) In /etc/mysql/my.cnf modify the bind-address variable by either 1.) commenting it out or 2.) changing it to Doing either of these will now allow outside connections.

2.) Next you’ll need a user that is authorized to access the database from a remote IP.

GRANT ALL ON database_name.* TO IDENTIFIED BY 'your_password'; 

the should be the remote IP address you will be accessing the database from. This can also be set as a wildcard to allow the user acccess from any IP but generally this is not a good idea unless the server connecting to the database has a dynamic IP or cannot be predicted for another reason.