# install unixODBC and mysql-connector-odbc
yum install unixODBC mysql-connector-odbc
#view the basics of your config in a nice info file
odbcinst -j
#view the ODBC config instance file, this is for different database types.as you can see MySQL and PostgreSQL are allready configured
cat /etc/odbcinst.ini
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/psqlodbcw.so
Setup=/usr/lib/libodbcpsqlS.so
Driver64=/usr/lib64/psqlodbcw.so
Setup64=/usr/lib64/libodbcpsqlS.so
FileUsage=1
UsageCount=5
[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/libmyodbc5.so
Setup=/usr/lib/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1
UsageCount=5
#from here we need to create specific instances/connections.
vi /etc/odbc.ini
#here’s a look at a sample ODBC connection config,remote database connect info
[EAM]
Description=MySQL connection to 'assetcloud' database
Trace=OFF
TraceFile=stderr
Driver=MySQL
SERVER=121.41.113.120
PORT=3306
DATABASE=assetcloud
USERNAME=mysql
PASSWORD=123456
#from here install the ODBC driver, and install SystemDSN
odbcinst -i -d -f /etc/odbc.inst.ini
odbcinst -i -s -l -f /etc/odbc.inst.ini
#test the connection using the Database name {space} username
isql EAM mysql
#as we can see basic SQL Queries work
SHOW DATABASES;
select * from users;
使用odbcinst -q -d时,出现错误:
odbcinst: SQLGetPrivateProfileString failed with .
办法:env |grep 'ODBC'
如无法找到环境变量ODBCSYSINI和ODBCINI,则:
vi /etc/profile
增加如下内容:
export ODBCSYSINI=/etc
export ODBCINI=/etc/odbc.ini
另外,如果在linux下使用make,出现如下错误:
configure: error: no acceptable C compiler found in $PATH
解决办法:yum -y install gcc gcc-c++ gdb