1

我在使用 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).

这里有什么问题?

4

1 回答 1

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.

于 2019-01-15T18:23:46.387 回答