编译时提示头文件#include <mysql/mysql.h>不存在,百度之后也没解决

#include <mysql/mysql.h>

MYSQL *conn;

MYSQL_RES *res;

MYSQL_ROW *row;


char *server = "localhost";

char *user = "root";

char *password = "1";


conn = mysql_init(NULL);

if(!mysql_real_connect (conn,server,user,password,database,0,NULL,0))

{

    fprintf(stderr,"%s\n",mysql_error(conn));

    exit(1);

}

if(mysql_real_query(conn,"select * from student"))

{

    fprintf(stderr,"%s\n",mysql_error(conn));

    exit(1);

}

res = mysql_use_result(conn);

while((row = mysql_fetch_row(res)) != NULL)

{

    printf("%s\t%s\t%s\n",row[0],row[1],row[2]);

}

mysql_free_result(res);

mysql_close(conn);


杨魅力
浏览 1191回答 2
2回答

慕仙森

$&nbsp;sudo&nbsp;yum&nbsp;install&nbsp;mysql-devel&nbsp;-y&nbsp;&nbsp;&nbsp;&nbsp;//RHEL,Centos,Fedora $&nbsp;sudo&nbsp;apt-get&nbsp;install&nbsp;libmysqlclient-dev&nbsp;-y&nbsp;&nbsp;//Ubuntu如果已经安装成功了,找到mysql.h的文件路径,-I&nbsp;编译即可$&nbsp;sudo&nbsp;&nbsp;find&nbsp;/usr/&nbsp;-name&nbsp;'mysql.h' $&nbsp;gcc&nbsp;-I/usr/include/mysql&nbsp;...
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL