MySQL Forums
Forum List  »  Chinese

linux ODBC连接mysql
Posted by: Junquan Liu
Date: August 28, 2013 11:38PM

想通过oracle连接mysql,根据网上的指引,先安装unixODBC,然后安装mysql connector/ODBC。
[root@test unixODBC-2.3.1]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

但装完mysql connector/ODBC,又提示我odbc.ini,odbcinst.ini在/etc/unixODBC下(上面显示odbc.ini路径为/usr/local/etc)
于是,我把环境变量export ODBCINI=/etc/unixODBC/odbc.ini
[oracle@test ~]$ more $ODBCINI
[ODBC Data Sources]
myodbc3 = MyODBC 3.51 Driver DSN

[myodbc3]
Driver = /usr/lib64/libmyodbc3.so
Description = MyODBC 3.51 Driver DSN
SERVER = 192.168.0.1
PORT = 3306
USER = root
PASSWORD = test
DATABASE = dbtest
OPTION = 3
SOCKET =

[Default]
Driver = /usr/lib64/libmyodbc3.so
Description = MyODBC 3.51 Driver DSN
SERVER = 192.168.0.1
PORT = 3306
USER = root
PASSWORD = test
DATABASE = dbtest
OPTION = 3
SOCKET =

另外,mysql的情况如下:
mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+-----------+--------------+-------------------------------------------+
| host | user | password |
+-----------+--------------+-------------------------------------------+
| localhost | asteriskuser | *74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3 |
| % | root | *74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3 |
+-----------+--------------+-------------------------------------------+


而在客户端用isql时报错如下:
[oracle@test ~]$ isql -v myodbc3 root test
[S1000][unixODBC][MySQL][ODBC 3.51 Driver]Unknown database 'dbtest'
[ISQL]ERROR: Could not SQLConnect


对mysql、unixODBC、myodbc不熟,请各位指导,谢谢!

Options: ReplyQuote


Subject
Views
Written By
Posted
linux ODBC连接mysql
34778
August 28, 2013 11:38PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.