C++连接mysql
2023-09-14 09:02:20 时间
(1)包含目录中,填入mysql的include
(2)添加对附加
path_to_myql\lib\libmysql.lib
(3)确保测试的工程是 64位的
(4)测试的代码进行测试
#include <iostream> #include <mysql.h> using namespace std; int main() { MYSQL mysql; mysql_init(&mysql); const char *host = "127.0.0.1"; const char *user = "root"; const char *pass = "root"; const char *db = "wlxmysql"; // 数据库名称(已存在) if (!mysql_real_connect(&mysql, host, user, pass, db, 3306, 0, 0)) { cout << "Failed" << endl; } else { cout << "success" << endl; } system("pause"); return 0; }
参考文章
vs2017C++连接MySql数据库, 20.2
相关文章
- 【C/C++学院】(22)Mysql数据库编程--C语言操作数据库
- 01.MySql连接错误:Cannot get hostname for your address
- 统一观测丨如何使用 Prometheus 监控 MySQL
- 【转载】MySQL Query Cache 小结
- mysql修改自增id从固定值开始
- MySQL存储过程(四)——存储过程循环流控语句
- MySQL存储过程(一)——存储过程理论基础
- RDS MySQL空间优化最佳实践
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
- mysql 锁
- 解决办法:Linux mysql命令 -bash: mysql: command not found 找不到命令