basic help with c++ connector 8.0.23 :-(


I have used many databases in my my Digital Ocean droplets before. I typically use PHP but in this occasion I need to use c++. I downloaded the dev.mysql connector for c++, nothing else. Is not my plan to run this locally in my machine.

After installing and configuring it, I was finally able to compile some code. The problem is that I can’t establish a connection from the compiler. I don’t suspect any type of connectivity issue, since I can ssh to my droplet all day long.

In a nutshell, this is my code:

#include <iostream>
#include <mysqlx/xdevapi.h>

int main(){


   mysqlx::SessionSettings option_list(
            SessionOption::USER, "root",
            SessionOption::PWD, "password",
            SessionOption::HOST, "",
            SessionOption::PORT, 3306,
            SessionOption::DB, "test_database");

   mysqlx::session sess(option_list);

   std::cout << "yeah this works" << std::endl;

catch(exception e){

std::cout << e.what() << std::endl;


I realize the code above may seem offensively bad, but please help me.

For example, are my options right? I have played with several combinations. I even used SSL enabled or disabled, whatever that is.

How does it log in into the droplet first? I ask because if I was using myheidysql there are two logins, one for the droplet and one for mysql inside the droplet. My code doesn’t do that and in PHP, well the files were already inside the droplet. Both mysql and my droplet have identical users and passwords for simplicity.

Any pointers for me? I am using XDev c++ Dynamic option.

Thank you so much. I would also read any tutorial, but they are all outdated or assumed I am more advanced, which is not the case.


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer