I have an ipv6 mysql server. I wanna develop a windows's client using connector/C++ which can connect to my mysql server. If mysql uses an ipv4 address, I can program like this:
mysql::MySQL_Driver *driver;
Connection *con;
Statement *state;
ResultSet *result;
/* init driver */
driver = sql::mysql::get_mysql_driver_instance();
/* try to connect */
con = driver->connect("tcp://127.0.0.1:3306", "root", "123");
state = con->createStatement();
state->execute("use test");
/* query */
result = state->executeQuery("select * from testuser where id < 1002");
How do I program if I want to use an ipv6 address for mysql? Please, thanks~
You should be able to place the IPv6 address in brackets, for instance:
con = driver->connect("tcp://[::1]:3306", "root", "123");
Be sure that your MySQL server is actually listening on IPv6. MySQL versions before 5.5 did not support IPv6.