我试图从C代码连接到mysql服务器。
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
main(){
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "12345"; /* set me first */
char *database = "mydatabase";
conn = mysql_init(NULL);
printf("done 1\n");
if (!mysql_real_connect(conn, server,
user, password, database, 3306, "/tmp/mysql.sock", 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
printf("done 2\n");
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
printf("done 3\n");
res = mysql_use_result(conn);
printf("done 4\n");
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
printf("done 5\n");
mysql_free_result(res);
mysql_close(conn);
}
但是我有一个奇怪的问题:
done 1
Plugin caching_sha2_password could not be loaded: /usr//usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
我不知道为什么它试图从 / usr // usr /
加载lib如果您已经处理过,请提供帮助!