易截截图软件、单文件、免安装、纯绿色、仅160KB

使用MySQL connector/C++链接MySQL数据库

首先去MySQL官网下载MySQL connector/C++
http://dev.mysql.com/downloads/connector/cpp/1.0.html
下载第二个包,windows32位非安装版(个人觉得这个包干净)。目前的版本是Connector/C++ 1.0.5。
Windows (x86, 32-bit), ZIP Archive
(mysql-connector-c++-noinstall-1.0.5-win32.zip)
将整个包解压到项目文件夹下的的源文件目录。文件夹名字太长,将“mysql-connector-c++-noinstall-1.0.5-win32”改为“mysql”。
下面要配置vs2008的环境。
1. 项目属性页->C/C++->General->Additional Include Directories。将mysql\include目录和mysql\include\cppconn目录添加进去。
2. 项目属性页->Linker->General->Additional Library Directories。将mysql\lib目录添加进去。
3. 项目属性页->Linker->Input->Additional Dependencies。添加这两项mysqlcppconn.lib,mysqlcppconn-static.lib(mysql\lib目录下的两个.lib文件)
4. 将mysql\lib下的mysqlcppconn.dll文件复制到windows\system32文件夹下。
环境配置完毕。
在连接数据库之前,先建立一张表。
(其实这些可以在代码中完成,我这样是为了让测试代码尽可能简练易查错)
打开控制台,输入mysql -u root -p,输入密码。
查看当前已有的数据库。(SQL语句末尾加上';'表示立即执行当前语句。)
mysql> show databases;
创建数据库
mysql> create database test;
使用数据库(这句不能加分号)
mysql> use test
查看已有的表
mysql> show tables;
创建表
mysql> create table testuser ( id INT, name CHAR(20));
插入数据
mysql> insert into testuser(id, name) values(1001, 'google');
mysql> insert into testuser(id, name) values(1002, 'kingsoft');
mysql> insert into testuser(id, name) values(1003, 'firefox');
现在在C++中查询这些数据
#include "stdafx.h"
#include <mysql_connection.h>
#include <mysql_driver.h>
#include <statement.h>
using namespace sql;
using namespace std;
void RunConnectMySQL()
{
mysql::MySQL_Driver *driver;
Connection *con;
Statement *state;
ResultSet *result;
// 初始化驱动
driver = sql::mysql::get_mysql_driver_instance();
// 建立链接
con = driver->connect("tc


相关文档:

ubuntu下更改mysql默认编码(字符集)

 
安装mysql
sudo apt-get install mysql-server #直接自动获得可用版本
也可以这样写
sudo apt-get install mysql-server-5.0 #安装mysql服务器5.0版本
安装后
/etc/init.d/mysql start (stop) 为启动和停止服务器
/etc/mysql/ 主要配置文件所在位置 my.cnf
/var/lib/mysql/ 放置的是数据库表文件夹,这里的m ......

创建oracle访问mysql的数据链路步骤

(1)登陆到mysql
C:\Documents and Settings\Administrator>mysql -h localhost -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 69
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' fo ......

PHP中的MYSQL常用函数总结

PHP中的MYSQL常用函数总结
1、mysql_connect()-建立数据库连接
格式:
    resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
例:
    $conn = @mysql_connect("localhost", "username", "password") or dir( ......

mysql设置bit类型数据


数据库的一张表里面存了关于一台设备的备份配置信息,类型是bit,主要就是是否已经配置,设置的时候取值是true,false,还是0,1呢?
纠结了半天,动手就好了,是0,1,而非true,false,
更新语句如下
update  table_a
set configBaked= 0
where id in (2,3,4)
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号