#include <stdio.h>
#include <mysql.h> // functions from libmysqlclient
int main(int argc, char *argv[])
{
int i;
MYSQL *conn; // connection
MYSQL_RES *result; // result of the SELECT query
MYSQL_ROW row; // a record of the SELECT query
// create connection to MySQL
conn = mysql_init(NULL);
if(mysql_real_connect(conn, "mysql", "usr", "1234", "db1", 0, NULL, 0) == NULL) {
fprintf(stderr, "sorry, no database connection ...\n");
return 1;
}
// only if Unicode output (utf8) is desired
mysql_query(conn, "SET NAMES 'utf8'");
// create list of all pulishers and number of titles published for each pulisher
const char *sql="SELECT COUNT(titleID), publName \
FROM publishers, titles \
WHERE publishers.publID = titles.publID \
GROUP BY publishers.publID \
ORDER BY publName";
if(mysql_query(conn, sql)) {
fprintf(stderr, "%s\n", mysql_error(conn));
fprintf(stderr, "%s\n", sql);
return 1;
}
// process result
result = mysql_store_result(conn);
if(result<span style="c上面是一段在linux访问mysql的代码,我是FC 7.0安装时候自己带的mysql,可我在系统中怎么也找不到#include <mysql.h> ,是没有装吗?还是要另安装什么包??所以一直没有办法连接mysql数据库,请大家帮帮我
在线等待
可能在 /usr/local/include/mysql/ 这个目录里面了吧