首先在MYSQL中创建好数据库和表,数据库打开时才能连接上
在设置VS2010环境,添加include的路径到附加包含目录,添加lib的路径到添加库目录
复制libmySQL.dll、libmysql.lib两个文件到工程
然后申明
#include "stdafx.h"
#include "mysql.h"
#include ‘‘winsock.h"
#include "windows.h"
#include <stdio.h>
#include <string.h>
#pragma comment(lib,"libmySQL.lib")
#pragma comment(lib,"mysqlclient.lib")
连接mysql
mysql_init(&mysql);
mysql_real_connect(&mysql,"localhost","root","smartcard",3306,NULL,0);
原文地址:https://www.cnblogs.com/setoff/p/8656522.html
时间: 2024-10-18 09:59:58