Search code examples
c++mysqldatabasesinglestoresqlapi++

Cannot connect to MemSQL through SQLApi++


I'm trying to connect to MemSQL database from c++ code and I'm using SQLApi++ library. MySQL client is compatible with MemSQL and SQLApi++ has support of MySQL. However I can't connect and get different errors.

For example, I'm calling connect with the following parameters

Connect("tcp://localhost:3307", "root", "", SA_MySQL_Client)

and get an error saying Access denied for user 'root'@'localhost' (using password: NO).

I have searched on the internet and tried several versions of specifying DB hostname, however non of them have worked. What am I doing wrong? What is the correct version? Any Ideas?

NOTE: I can successfully connect to MemSQL with command-line by just executing memsql -P 3307.


Solution

  • When I provided local IP address and port, for some reason SQLApi++ ignored it and always tried to connect to MySQL's socket in default path (i.e. /var/lib/mysql/mysql.sock).

    However, after reading documentation once more, it turned out that it is possible to pass socket's path as a host name. So I passed MemSQL's socket path and it worked!