Int main (INT argc, char * argv []) {const char * Host = "localhost"; // host const char * user = "root "; // username const char * passwd = "12321"; // password const char * DB = "mydb"; // database name unsigned int Port = 3306; // MySQL port const char * unix_socket = 0; unsigned long client_flag = 0; MySQL; mysql_res * result; mysql_field * field; mysql_row SQL _row; string temp_time = getnewtime (3 ); string SQL _select = "select kid, keyword_hash, Keyword, record_time from words_realtime where record_time <'"+ temp_time +"' "; mysql_library_init (0, null, null); // initialize MySQL C apimysql_init (& MySQL ); mysql_options (& MySQL, mysql_set_charset_name, "GBK"); If (mysql_real_connect (& MySQL, host, user, passwd, DB, port, unix_socket, client_flag )) {cout <"database connection OK! "<Endl; int res = mysql_query (& MySQL, SQL _select.c_str (); If (! Res) {// mysql_query returns 0 cout after successful execution <"query success! "<Endl; Result = mysql_store_result (& MySQL); If (result) {int I, j; cout <" Number of result: "<(unsigned long) mysql_num_rows (result) <Endl; for (I = 0; field = mysql_fetch_field (result); I ++) // obtain the column name {cout <field-> name <"" ;}cout <Endl; while (SQL _row = mysql_fetch_row (result) {for (I = 0; I <mysql_num_fields (result); I ++) {cout <SQL _row [I] <"" ;}cout <Endl ;}}} else {cout <mysql_error (& MySQL) <Endl ;}} mysql_close (& MySQL); System ("pause"); Return 0 ;}