Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ MySQL C++;连接器_C++_Mysql - Fatal编程技术网

C++ MySQL C++;连接器

C++ MySQL C++;连接器,c++,mysql,C++,Mysql,我正在使用MySQL/C++连接器。 我已在此中尝试了“”提供的解决方案 然后我得到了这个错误: tester.cpp: In function ‘int main()’: tester.cpp:12:20: warning: variable ‘con’ set but not used [-Wunused-but-set-variable] sql::Connection *con; ^ /usr/lib/libmysqlcppconn.a(my


我正在使用MySQL/C++连接器。
我已在此中尝试了“”提供的解决方案
然后我得到了这个错误:

tester.cpp: In function ‘int main()’: tester.cpp:12:20: warning: variable ‘con’ set but not used [-Wunused-but-set-variable] sql::Connection *con; ^ /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::affected_rows(st_mysql*)': (.text+0x164): undefined reference to `mysql_affected_rows' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::autocommit(st_mysql*, char)': (.text+0x18d): undefined reference to `mysql_autocommit' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::close(st_mysql*)': (.text+0x1ac): undefined reference to `mysql_close' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::commit(st_mysql*)': (.text+0x1ca): undefined reference to `mysql_commit' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::data_seek(st_mysql_res*, unsigned long long)': (.text+0x1f3): undefined reference to `mysql_data_seek' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::debug(char const*)': (.text+0x212): undefined reference to `mysql_debug' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::mysql_errno(st_mysql*)': (.text+0x230): undefined reference to `mysql_errno' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::error(st_mysql*)': (.text+0x24e): undefined reference to `mysql_error' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_field(st_mysql_res*)': (.text+0x26c): undefined reference to `mysql_fetch_field' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_field_direct(st_mysql_res*, unsigned int)': (.text+0x292): undefined reference to `mysql_fetch_field_direct' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_lengths(st_mysql_res*)': (.text+0x2b0): undefined reference to `mysql_fetch_lengths' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_row(st_mysql_res*)': (.text+0x2ce): undefined reference to `mysql_fetch_row' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::field_count(st_mysql*)': (.text+0x2ec): undefined reference to `mysql_field_count' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::free_result(st_mysql_res*)': (.text+0x30a): undefined reference to `mysql_free_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::get_client_version()': (.text+0x31d): undefined reference to `mysql_get_client_version' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::get_server_info(st_mysql*)': (.text+0x33c): undefined reference to `mysql_get_server_info' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::get_server_version(st_mysql*)': (.text+0x35a): undefined reference to `mysql_get_server_version' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::info(st_mysql*)': (.text+0x378): undefined reference to `mysql_info' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::init(st_mysql*)': (.text+0x396): undefined reference to `mysql_init' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::library_init(int, char**, char**)': (.text+0x3c4): undefined reference to `mysql_server_init' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::library_end()': (.text+0x3d7): undefined reference to `mysql_server_end' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::more_results(st_mysql*)': (.text+0x3f6): undefined reference to `mysql_more_results' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::next_result(st_mysql*)': (.text+0x414): undefined reference to `mysql_next_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::num_fields(st_mysql_res*)': (.text+0x432): undefined reference to `mysql_num_fields' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::num_rows(st_mysql_res*)': (.text+0x450): undefined reference to `mysql_num_rows' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::options(st_mysql*, mysql_option, void const*)': (.text+0x47e): undefined reference to `mysql_options' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::query(st_mysql*, char const*)': (.text+0x4a7): undefined reference to `mysql_query' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::ping(st_mysql*)': (.text+0x4c6): undefined reference to `mysql_ping' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::real_connect(st_mysql*, char const*, char const*, char const*, char const*, unsigned int, char const*, unsigned long)': (.text+0x519): undefined reference to `mysql_real_connect' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::real_escape_string(st_mysql*, char*, char const*, unsigned long)': (.text+0x550): undefined reference to `mysql_real_escape_string' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::real_query(st_mysql*, char const*, unsigned long)': (.text+0x581): undefined reference to `mysql_real_query' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::rollback(st_mysql*)': (.text+0x5a0): undefined reference to `mysql_rollback' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::sqlstate(st_mysql*)': (.text+0x5be): undefined reference to `mysql_sqlstate' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::ssl_set(st_mysql*, char const*, char const*, char const*, char const*, char const*)': (.text+0x603): undefined reference to `mysql_ssl_set' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::store_result(st_mysql*)': (.text+0x622): undefined reference to `mysql_store_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::use_result(st_mysql*)': (.text+0x640): undefined reference to `mysql_use_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::warning_count(st_mysql*)': (.text+0x65e): undefined reference to `mysql_warning_count' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_affected_rows(st_mysql_stmt*)': (.text+0x67c): undefined reference to `mysql_stmt_affected_rows' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_attr_set(st_mysql_stmt*, enum_stmt_attr_type, void const*)': (.text+0x6aa): undefined reference to `mysql_stmt_attr_set' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_bind_param(st_mysql_stmt*, st_mysql_bind*)': (.text+0x6d3): undefined reference to `mysql_stmt_bind_param' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_bind_result(st_mysql_stmt*, st_mysql_bind*)': (.text+0x6fd): undefined reference to `mysql_stmt_bind_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_close(st_mysql_stmt*)': (.text+0x71c): undefined reference to `mysql_stmt_close' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_data_seek(st_mysql_stmt*, unsigned long long)': (.text+0x745): undefined reference to `mysql_stmt_data_seek' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_errno(st_mysql_stmt*)': (.text+0x764): undefined reference to `mysql_stmt_errno' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_error(st_mysql_stmt*)': (.text+0x782): undefined reference to `mysql_stmt_error' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_execute(st_mysql_stmt*)': (.text+0x7a0): undefined reference to `mysql_stmt_execute' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_fetch(st_mysql_stmt*)': (.text+0x7be): undefined reference to `mysql_stmt_fetch' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_field_count(st_mysql_stmt*)': (.text+0x7dc): undefined reference to `mysql_stmt_field_count' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_init(st_mysql*)': (.text+0x7fa): undefined reference to `mysql_stmt_init' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_num_rows(st_mysql_stmt*)': (.text+0x818): undefined reference to `mysql_stmt_num_rows' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_param_count(st_mysql_stmt*)': (.text+0x836): undefined reference to `mysql_stmt_param_count' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_prepare(st_mysql_stmt*, char const*, unsigned long)': (.text+0x867): undefined reference to `mysql_stmt_prepare' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_result_metadata(st_mysql_stmt*)': (.text+0x886): undefined reference to `mysql_stmt_result_metadata' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_send_long_data(st_mysql_stmt*, unsigned int, char const*, unsigned long)': (.text+0x8ba): undefined reference to `mysql_stmt_send_long_data' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_sqlstate(st_mysql_stmt*)': (.text+0x8d8): undefined reference to `mysql_stmt_sqlstate' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_store_result(st_mysql_stmt*)': (.text+0x8f6): undefined reference to `mysql_stmt_store_result' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_end()': (.text+0x909): undefined reference to `mysql_thread_end' /usr/lib/libmysqlcppconn.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_init()': (.text+0x91d): undefined reference to `mysql_thread_init' collect2: error: ld returned 1 exit status tester.cpp:在函数“int main()”中: tester.cpp:12:20:警告:变量“con”已设置但未使用[-Wunused但已设置变量] 连接*con; ^ /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::infected_rows(st_mysql*)中: (.text+0x164):未定义对“mysql\u受影响的行”的引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::autocommit(st_mysql*,char)' (.text+0x18d):对“mysql\u自动提交”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::close(st_mysql*)中: (.text+0x1ac):对“mysql\u close”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::commit(st_mysql*)中: (.text+0x1ca):对“mysql\u commit”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::data_seek(st_mysql_res*,unsigned long long')中: (.text+0x1f3):对“mysql\u data\u seek”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::debug(char const*)中: (.text+0x212):对“mysql\u debug”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::mysql\u errno(st_mysql*)中: (.text+0x230):对“mysql\u errno”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::error(st_mysql*)中: (.text+0x24e):未定义对“mysql\u错误”的引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch\u field(st_mysql\u res*)”中: (.text+0x26c):对“mysql\u fetch\u字段”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_field_direct(st_mysql_res*,unsigned int')中: (.text+0x292):对“mysql\u fetch\u field\u direct”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_length(st_mysql_res*)中: (.text+0x2b0):对“mysql\u fetch\u length”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch\u row(st_mysql\u res*)”中: (.text+0x2ce):对“mysql\u fetch\u行”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::field_count(st_mysql*)'中: (.text+0x2ec):对“mysql\u字段\u计数”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::free\u result(st_mysql\u res*)”中: (.text+0x30a):对“mysql\u free\u result”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::get\u client\u version()'中: (.text+0x31d):对“mysql\u get\u client\u version”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::get_server\u info(st_mysql*)”中: (.text+0x33c):对“mysql\u get\u server\u info”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::get\u server\u version(st\u mysql*)”中: (.text+0x35a):未定义对“mysql\u get\u server\u version”的引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::info(st_mysql*)中: (.text+0x378):未定义对“mysql\u info”的引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::init(st_mysql*)”中: (.text+0x396):对“mysql_init”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::LibmysqlStaticProxy::library_init(int,char**,char**')中: (.text+0x3c4):对“mysql\u server\u init”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::LibmysqlStaticProxy::library_end()'中: (.text+0x3d7):对“mysql\u服务器\u端”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::more_results(st_mysql*)中: (.text+0x3f6):对“mysql\u更多\u结果”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::next_result(st_mysql*)中: (.text+0x414):对“mysql\u next\u result”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::num\u fields(st_mysql\u res*)”中: (.text+0x432):对“mysql\u num\u字段”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::num_rows(st_mysql_res*)中: (.text+0x450):对“mysql\u num\u行”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::options(st_mysql*,mysql\u option,void const*)中: (.text+0x47e):未定义对“mysql\u选项”的引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::query(st_mysql*,char const*)中: (.text+0x4a7):对“mysql\u查询”的未定义引用 /usr/lib/libmysqlcppcconn.a(mysql\u client\u api.cpp.o):在函数“sql::mysql::NativeAPI::LibmysqlStaticProxy::ping(st_mysql*)”中: (.text+0x4c6):未定义对“mysql\u-ping”的引用 /usr/lib/libmysqlcppcconn.a(mysql_client_api.cpp.o):在函数'sql::mysql::NativeAPI::LibmysqlStaticProxy::real_connect(st_mysql*,char const*,char const*,char const*,char const*,unsigned int,char const*,unsigned long)': (.text+0x519) tester.cpp: In function ‘int main()’: tester.cpp:12:20: warning: variable ‘con’ set but not used [-Wunused-but-set-variable] sql::Connection *con; ^ /tmp/ccSdYfYy.o: In function `main': tester.cpp:(.text+0xa): undefined reference to `get_driver_instance' collect2: error: ld returned 1 exit status
#include <stdlib.h>
#include <iostream>
#include <mysql_connection.h>
#include <driver.h>
#include <exception.h>
#include <resultset.h>
#include <statement.h>

using namespace sql;
int main(void){
  sql::Driver *driver;
  sql::Connection *con;

  driver = get_driver_instance();
  con = driver->connect("tcp://127.0.0.1:3306","root","YOURPASSWORD");

  return 0;
}
1. Install mysqlcppconn : sudo apt-get install libmysqlcppconn-dev 2. Install mysqlclient : sudo apt-get install libmysqlclient-dev libmysqlclient18 3. Compile it in terminal using : sudo g++ -Wall -I/usr/include/cppconn -o testapp tester.cpp -L/usr/lib -lmysqlcppconn -lmysqlclient