我正在尝试使用构建连接器 c++ 通过 C++ 代码登录 MySQL,这是我删除密码的代码:
std::string url = "mysqlx://localhost:3306/license_db?user=licuser&password=************";
session mySession(url);
mySession.sql("使用license_db").execute();
自动结果 = mySession.sql("SELECT * FROM 产品").execute();
行 row1 = result.fetchOne();
代码导致“Session mySession(url);”出现异常行,异常显示“错误分配”。
有人可以帮忙吗?
最佳答案
X DevAPI 的 URI 通常为 mysqlx://user:password@host:3306/schema,适用于 JS、PHP 和 Python。
https://dev.mysql.com/doc/x-devapi-userguide/en/database-connection-example.html 有一个示例对于 C++
var mySession = MySQLX.GetSession("server=localhost;port=33060;user=user;password=password;");
关于c++ - 如何使用 xdevapi 通过 C++ 代码登录 MySQL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54131777/