Reputation: 4019
I am accessing a MySQL database within a C++ app using MySQL C++ Connector. It works fine if I have the C++ and the MySQL on the same machine. So, something like the following code works fine:
sql::Connection *_con;
sql::mysql::MySQL_Driver *_driver;
_driver = sql::mysql::get_mysql_driver_instance();
_con = _driver->connect("tcp://127.0.0.1:3306", "user", "password");
However, I can't seem to access the database if it is located on another machine. So, something like this:
sql::Connection *_con;
sql::mysql::MySQL_Driver *_driver;
_driver = sql::mysql::get_mysql_driver_instance();
_con = _driver->connect("tcp://somesite.com:3306", "user", "password");
Is it just not possible or am I doing something wrong?
Upvotes: 0
Views: 2292
Reputation: 22300
Did you accidentally setup your users so that they can only access your DB from the local machine?
Did you do
create user 'user'@'127.0.0.1' ...
or
create user 'user'@'%' ....
If you did the first then you won't be able to log on from a different machine.
Did you also grant the privileges correctly?
See the MySQL docs for a more in depth explanation on how to do this correctly
Upvotes: 3
Reputation: 163
I have done this through a VPN so I am assuming it is possible. Are you using the correct port?
Upvotes: 1