linux 下链接mysql练习
2016-03-14 21:17
309 查看
编译命令如下
hzz@hzz-pc:~/code/testCode$ g++ -I /usr/include/mysql/ /home/hzz/code/testCode/connect2.c -L /usr/lib/mysql -lmysqlclient -o connection2
hzz@hzz-pc:~/code/testCode$ ./connection2
hzz@hzz-pc:~/code/testCode$ g++ -I /usr/include/mysql/ /home/hzz/code/testCode/connect2.c -L /usr/lib/mysql -lmysqlclient -o connection2
hzz@hzz-pc:~/code/testCode$ ./connection2
#include <stdlib.h> #include <stdio.h> #include "mysql.h" int main(int argc,char *arg[]) { MYSQL myconnection; mysql_init(&myconnection); if(mysql_real_connect(&myconnection,"localhost","test","test","testDb1",0,NULL,0)) { printf("connection success"); mysql_close(&myconnection); } else { fprintf(stderr,"connection failed\n"); if(mysql_errno(&myconnection)) { fprintf(stderr,"Connection error %d %s",mysql_errno(&myconnection),mysql_error(&myconnection)); } } return 0; }
相关文章推荐
- Linux下查看cpuinfo相关信息注释
- linux第11天 共享内存和信号量
- linux基础命令1
- 《Linux内核设计与实现》读书笔记 第二章 从内核出发
- Linux文件系统之新建分区(fdisk命令)
- Linux 截图工具-shutter
- CentOs安装JDK过程中的小坑
- linux命令介绍(3)
- 搭建 CentOS 6 服务器(14) - CVS、SVN、Git
- 【Linux进程间通信】 - 共享内存
- linux内核分析四
- Linux 下解决pthread_create undefined reference 方法
- Linux 设备驱动开发 —— 设备树在platform设备驱动中的使用
- Linux下的常用终端调试指令(2)
- Linux 下的GDB常用终端命令(1)
- linux语法
- Linux系统下安装Git
- linux设备驱动程序注册过程详解
- LINUX下JNI封装 C++动态链接库
- 本地linux下安装discuz