#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
#include <WinSock2.h>
#include <mysql.h>
#include <windows.h>
void *thread_fun(void *);
int main()
{
pthread_t thread_id[10];
int i;
//MYSQL mysql;
//if(mysql_init(&mysql)==NULL)
// return -1;
for( i = 0; i < 10; i++)
{
pthread_create(&thread_id[i], NULL, thread_fun, NULL);
}
for(i = 0; i < 10 ; i++)
{
pthread_join(thread_id[i], NULL);
}
return 0;
}
void *thread_fun(void *ptr)
{
MYSQL mysql;
MYSQL_RES * result;
MYSQL_ROW row;
const char * host = "localhost";
const char * user = "root";
const char * passwd = "123456";
const char * db = "testmysql";
if(mysql_init(&mysql)==NULL)
exit(1);
mysql_thread_init()
windows下连接mysql
最新推荐文章于 2021-04-24 12:02:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)