After the MySQL installation is successful, we can access it in a high-level language. Win7 Access method:
This test uses eclipse, compiled with MINGW64
First, include the path, then include the library, and also note that the Libmysql is listed separately.
The C + + test code is:
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include "mysql.h"
int main (int argc, char* argv[])
{
int res,j;
MySQL MySQL;
Mysql_res *resultset;
Mysql_row ROW;
Mysql_init (&mysql);//Initialize MySQL
Password change to your own password, test for the database name, your own any one, root for the user name, other basic fixed
if (!mysql_real_connect (&mysql, "localhost", "root", "password", "Test", 3306, NULL, 0))
{
printf ("\ nthe database connection error");//Print success Information
}
Else
{
printf ("\ n database connection succeeded \ n"); //
}
Mysql_close (&mysql); Turn off MySQL
return 0;
}
Access MySQL database under Windows in C + +