Create an empty console program, create a CPP file, and add the following code. Code: # include <winsock2.h> // define socket # include <iostream> # include "MySQL. H "// # pragma comment (Lib," libmysql. lib "); // Add libmysql to the attached dependency. lib functions the same as usingnamespace STD; int main (char ** ARGs) {MySQL; mysql_init (& MySQL); If (mysql_real_connect (& MySQL, "localhost", "root ", "", "test", 3306, 0, 0) {cout <"OK" <Endl; return 0 ;}else {int I = mysql_errno (& MySQL ); constchar * s = mysql_error (& MySQL); cout <S <Endl;} related settings: 1. Add the directory containing the header file, include is the mysql-5.0.27-win32/include folder. 2, additional library directory, MySQL lib file is mysql-5.0.27-win32/lib/OPT file 3, additional dependencies, name libmysql. Lib
4. Copy libmysql. DLL to the debug folder. libmysql. dll contains