linux-unixODBC-mysql-c++_2012-0326

machineA:[real machine]{
os:win xp
ip:192.168.40.220
}


machineB:[in vmware]{
os:Linux xc 2.6.18-164.el5 #1 
SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux
ip:192.168.40.29
install iso:rhel-server-5.4-i386-dvd.iso
}


/etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux 
#baseurl=http://mirrors.163.com/centos/5/os/i386
baseurl=http://123.58.173.89/centos/5/os/i386
enabled=1
gpgcheck=0
gpgkey=http://123.58.173.89/RPM-GPG-KEY-CentOS-5


yum clean all
yum update


yum search mysql
yum install mysql-server.i386 mysql-connector-odbc.i386 -y
/etc/init.d/mysqld restart
mysql -h localhost -u root -p[ok]
[winxp]mysql -h 192.168.40.29 -u root -p[err:{]
ERROR 1130 (HY000): Host '192.168.40.220' is not allowed to connect to this MySQ
L server
[}]
mysql -h localhost -u root -p[exe sql:{]
use mysql
select host,user from user;
update user set host='192.168.40.220' where host='127.0.0.1';
[}]
/etc/init.d/mysqld restart
[in winxp]mysql -h 192.168.40.29 -u root -p[ok]


[upload]unix-odbc-demo.zip
[unzip]
cp unix-odbc-demo/odbc.ini /etc/odbc.ini


[/etc/odbc.ini:{]
[ub]
Driver      = mysql
Description = example
Server      = 192.168.40.29
Port        = 3306
Database    = db_demo
User        = root
Password    =
[}]


yum install gcc.i386 gcc-c++.i386 -y


g++ -c demo.cc -o demo.o[err:]
{no sql.h ...}


yum search unixODBC
yum install unixODBC-devel.i386 -y


 g++ -c demo.cc -o demo.o[ok]
 
 g++ -o demo demo.o -lodbc
 
 [in winXP, login mysqlServer, exec:{]
create database db_demo;
use db_demo;
create table tb_demo(i int);
insert into tb_demo(i) values(99);
insert into tb_demo(i) values(3);
 [}]
 
 ./demo [err:{]
[unixODBC][MySQL][ODBC 3.51 Driver]Host '192.168.40.29' is not allowed to connect to this MySQL server
[}]


[exec sql:{]
use mysql;
update user set host='192.168.40.29' where host='xc' and user='root';
[}]


/etc/init.d/mysqld restart


./demo[ok,output:{]
cnt=2
[}]


[what is 'xc']hostname[output:]
{xc}


link: full text + unix-odbc-demo.zip 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值