bitsCN.com
环境:mysql5.6.12(x64) 、visual studio 2013
语言:C++
步骤:
1.创建win32应用程序
2.添加include目录(%MYSQL_HOME%/include)(注:%MYSQL_HOME%替换为你的mysql安装目录)
立即学习“C++免费学习笔记(深入)”;
3.copy libmysql.lib和libmysql.dll到项目目录
4.创建文件source.cpp(注,请替换"***"为mysql登陆密码)
#include<winsock2.h>#include<mysql.h>#include<iostream>#pragma comment(lib,"libmysql.lib")int main(){ MYSQL mysql; mysql_init(&mysql); if (!mysql_real_connect(&mysql, "localhost", "root", "***", "test", 3306, NULL, 0)) { std::cout << "数据库连接失败" << std::endl; } else { std::cout << "连接成功" << std::endl; } return 0;}
c++怎么学习?c++怎么入门?c++在哪学?c++怎么学才快?不用担心,这里为大家提供了c++速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号