Mysql-connector-c-6.1.10-win32. zip for Windows, VS2015 Mysql, do not use the C ++ library, because the C ++ library depends on boost library \
Downloads.mysql.com/archives/c-…
Download mysql-connector-c-6.1.10-win32.zip and unzip it. Include and lib folders are required for client programming.
\
Second, client programming implementation
1. Copy the include and lib folders to the project directory
2. Copy the libmysql. DLL file from the lib folder to the exe directory
3, VS2015 engineering properties, configuration properties, C/C++, additional including directory write “.. \ \ include”
// mysqltest. CPP: defines the entry point for the console application. // #include "stdafx.h" #include<mysql.h>#define WIN32_LEAN_AND_MEAN #include<string>
#include <iostream>using namespace std; #pragma comment(lib, ".. /lib/libmysql.lib") int main() {// necessary data structure MYSQL mydata; //=mysql_init((MYSQL*)0); // Initialize the data structure if (NULL! = mysql_init(&mydata)) { cout << "mysql_init()succeed" << endl; } else { cout << "mysql_init()failed" << endl; return -1; If (0 == mysql_librARY_init (0, NULL, NULL)) {cout << "mysql_library_init()succeed" << endl; } else { cout << "mysql_library_init()failed" << endl; return -1; } // Connect to database if (NULL! = mysql_real_connect(& myDATA, "localhost", "root", "test", 3306, NULL, 0)) Cout << "mysql_real_connect()succeed" << endl; } else { cout << "mysql_real_connect()failed" << endl; return -1; } // Operation...... mysql_close(&mydata); system("pause"); return 0; }Copy the code
#define WIN32_LEAN_AND_MEAN \
\
\
\