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 

發佈了28 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章