我在使用mysql-connector-c ++ 8.0后遇到了很大的困难,现在我输入的uri就像在文档中提到的一样,但是连接被拒绝。
医生怎么说:
Client cli("user:password@host_name/db_name", ClientOption::POOL_MAX_SIZE, 7);
我的代码:
_mysql_client = std::make_unique<mysqlx::Client>("mysqlx://root:asdasd@localhost/asdasd");
try {
mysqlx::Session s = _mysql_client->getSession();
CoreLog->info("Successfully connected to mysql server on {}.", conn_uri);
} catch (const mysqlx::Error &err) {
CoreLog->info("Could not connect to mysql server on {} due to {}.", conn_uri, err.what());
}
我得到这个错误
[20:34:36.993] Core: Could not connect to mysql server on root:asdasd@localhost/asdasd due to CDK Error: Connection refused (generic:61).
这是什么问题?
答案 0 :(得分:1)
mysqlx::Client
is for connection to the new Mysql X protocol. This listens on a different port (33060 by default instead of 3306) which is the cause of the "connection refused" message.
You need to install and enable the Mysql protocol X plugin. See https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-install.html for instructions.