@
binaryify #6
#include <mysql/mysql.h>
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
int main(int argc, char *argv[])
{
MYSQL mysql;
mysql_init(&mysql);
if (mysql_real_connect(&mysql, "0.0.0.0", "root", "88888888", "sys", 3306, NULL, 0) == NULL)
{
cout << "mysql_real_connect failed(" << mysql_error(&mysql) << ")" << endl;
return -1;
}
mysql_set_character_set(&mysql, "utf-8");
MYSQL_RES *res;
MYSQL_ROW row;
int ret = mysql_query(&mysql, "select * from sys_config;");
res = mysql_store_result(&mysql);
cout << "variable "
<< "value "
<< "set_time " << endl;
while (row = mysql_fetch_row(res))
{
cout << row[0] << " ";
cout << row[1] << " ";
cout << row[2] << " ";
cout << endl;
}
mysql_free_result(res);
mysql_close(&mysql);
return 0;
}