1. the mysql-client package needs to be installed on the client, and the library file we need after installation; 2. Install the mysql-dev package. After installation, we need mysql. h file; 3,
1. the mysql-client package needs to be installed on the client, and the library file we need after installation; 2. Install the mysql-dev package. After installation, we need mysql. h file; 3,
1. the mysql-client package needs to be installed on the client. The library files we need after installation are complete;
2. Install the mysql-dev package. After installation, we need the mysql. h file;
3. As a client, you only need to install these two packages:
The following is a simple test code:
# Include
# Include
Int main ()
{
/* Declare ures and variables */
MYSQL mysql;
MYSQL_RES * result;
MYSQL_ROW row;
// Initialize MYSQL structure
Mysql_init (& mysql );
// Connect to database
// Mysql_real_connect (& mysql, "localhost", "root", "nriet", "test", 0, NULL, 0 );
Mysql_real_connect (& mysql, "192.168.13.27", "root", "nriet", "nriet", 0, NULL, 0 );
// Execute query
Mysql_query (& mysql, "select * from test ");
// Get result set
Result = mysql_store_result (& mysql );
// Process result set
While (row = mysql_fetch_row (result )))
{
Fprintf (stdout, "% s-% s \ n", row [0], row [1]);
}
// Mysql_query (& mysql, "insert into test values (3, 'A ')");
// Clean up
Mysql_free_result (result );
Mysql_close (& mysql );
}
4. "Libraries" under "gcc c ++ Linker ":
Libraries (-l): mysqlclient
Libraries search path (-L):/usr/lib/mysql
Then we can make it a success !!
,