How connect a Digital Ocean droplet to mysql db

Okay, so I need some quidance to getting things to work with Digital Ocean and linked to a mysql db.

don’t know where to start because I have been going through all documentation but there are still parts missing imho.

Let me explain what I did managed to get wroking;

  • create a DO target with a docker machine.

  • created a droplet on DO and managed to get the static part working with https This is all using the documentation  Now the next part is to get the local mySQL database running in Digital Ocean and connect it to the website

  • So I created a database cluster and database at my DO account Using a RazorSQL I exported my local database and created the same database in the DO database cluster. 
    Back to Wappler, Do I need to use these credentials in my Digital Ocean Target in Wappler? I tried that, but get a 500 error in the network status on the live site. 
    I also tried using the connection string from DO in the db ‘connection options’ Downloaded the certificate and placed it in the app folder After a redeploy I am getting this error:
    {

    • status: “500”,

    • message: “Cannot read property ‘ssl’ of undefined”,

    • stack: “TypeError: Cannot read property ‘ssl’ of undefined at App.setDbConnection (/opt/node_app/lib/core/app.js:250:37) at App.getDbConnection (/opt/node_app/lib/core/app.js:282:25) at new DatabaseProvider (/opt/node_app/lib/auth/database.js:9:23) at App.setAuthProvider (/opt/node_app/lib/core/app.js:173:26) at App.getAuthProvider (/opt/node_app/lib/core/app.js:190:31) at App.identify (/opt/node_app/lib/modules/auth.js:10:37) at App._exec (/opt/node_app/lib/core/app.js:449:57) at App.exec (/opt/node_app/lib/core/app.js:389:20) at App.define (/opt/node_app/lib/core/app.js:376:24)”}

  • Any ideas what to do next?

Do I need to change these setting also:?

Changing the db connection settings from global result in the ssl error. The ssl is the one downloaded from DO.

When I restart Wappler, some of the database connection: db settings have reverted back??
Host is reverted to “db”
the port is back at 3306
and ssl is turned off

Could it be that this has something to do with my problem not able to establish a connection?
The database Manager is also not able to connect to the remote database server (ECONNREFUSED)

Ok, I am trying again with a new clean docker machine. I removed the old target and added a new docker machine via Wappler.
As soon as I save the target I get the following error in the terminal:

If you want to use digital ocean managed database, you don’t need to enter also a docker database.

Just select none as docker database and create a database connection to your digital ocean database as explained in:

thanks George,
I don’t want a managed database. I didn’t realise that the mySQL is also working in the droplet.
Finally I managed go get things working.
One thing to ‘Wapp my head around’ is how to manage the remote database within Wappler.
After the first deploy a default table setup is created in the droplet.
Then in Wappler you can use the Database Manager and apply each step from the ‘changes’ folder.
Thing was that not all changes could be applied so I had to use an external sql editor to update the database in the dropet to match the local one.

So the workflow from now on will be as follows:

  • make changes locally and deploy locally for testing
  • if all ok, switch to the remote target and deploy
  • In the Database Manager apply each changed step to match the local db

Correct right?

Yes that is correct.

1 Like

At the moment I have my web app running in a Digital Ocean droplet (NodeJs and MySQL)

I want to separate the database to a database server on Digital Ocean.
Following the steps from the documentation I have:

  • created a database copy on the DO database server
  • Copied the connectionstring and pasted it in Wappler in the Globals -> Database connections -> db

What else should i do?
I deployed my app but it still uses the local db in the droplet

After a few trys and restarting Wappler a few times (it seems like Wappler didn’t save the settings) it is working now! :slightly_smiling_face: