1、#include <mysql/mysql.h>出错:
安装libmysql-dev:
sudo apt-get install libmysqld-dev
2、对‘mysql_init’未定义的引用:
链接lmsqlclient库文件(CMakeLists.txt添加):
LINK_DIRECTORIES(/usr/lib/x86_64-linux-gnu)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} -lmysqlclient)
3、mysql_real_connect()连接失败:
host不能为localhost,必须是IP(如:127.0.0.1)
password必须填写,不能为NULL