Search code examples
mysqlmysql-connectorsinglestore

Error connecting to memsql with mysql C connector


I'm trying to connect to memsql via mysql C connector:

MYSQL *connection = mysql_init(NULL);
mysql_real_connect(connection, HOST, USER, NULL, DBNAME, 0, NULL, 0);

but I get "Error in server handshake".

Connecting from the terminal (mysql -u root -h 127.0.0.1 -P 3306) works fine. I tried setting the root password, but nothing changes.

I also added SSL_MODE_DISABLED to mysql_options() and made sure SSL is disabled for memsql.

What could be the problem?


Solution

  • Which version of the MySQL C connector are you using? MySql changed the default authentication protocol in MySQL 8, so I would suggest using the older C connector (any version older than 8). If you want to use the MySQL 8 connector then you will need to pass along default-auth=mysql_native_password in some fashion.

    The same issue exists using the MySQL 8 C connector and connecting to an older version of MySQL (see https://bugs.mysql.com/bug.php?id=90994).