问题:mysql_real_connect()不会使用实际的ip与远程数据库建立连接
当前状态:mysql_real_connect()建立与本地数据库的连接。我正在使用Visual Studio Community 2017版本15.9.3,MySQL Workbench 8.0版本8.0.13和Connector.C ++ 1.1
void test_local_connection()
{
MYSQL* conn;
conn = mysql_init(0);
conn = mysql_real_connect(conn, "localhost", "root", "password1", "schema1",
3306, NULL, 0);
if (conn)
cout << "connection establised" << endl;
else error("connection failed - check settings");
}
问题:我需要将哪些特定参数传递给mysql_real_connect()才能与远程数据库建立连接? 是否必须使用root和root密码建立连接,或者可以建立连接 使用我的用户名和相应的密码?
void test_server_connection()
{
MYSQL* conn;
conn = mysql_init(0);
conn = mysql_real_connect(conn, "actual.ip.address", "user", "password2", "schema2", 3306, NULL, 0);
if (conn)
cout << "connection establised" << endl;
else error("connection failed - check settings");
}