odbc远程连接mysql,无法使用unixodbc,libmyodbc连接到远程mysql服务器

I'm a little green at this, and I hope the issue I'm having is a simple one...edit: new information at bottom

I need to make a connection to a remote mysql (Amazon RDS) database.

After following a few tutorials, I have unixodbc and libmyodbc installed and configured on the client, but when I try to connect via isql, I get the error

[08S01][unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

[ISQL]ERROR: Could not SQLConnect

The most confusing part about this error is that I'm not trying to connect to a local database, but rather to a remote one. I do not have a mysql.sock file on the client...this isn't the issue though is it?

I'm sensing a configuration error but I'm just not sure what it could be.

If I run odbcinst -j then the output is:

DRIVERS............: /etc/unixODBC/odbcinst.ini

SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini

USER DATA SOURCES..: /root/.odbc.ini

The content of /etc/unixODBC/odbcinst.ini is:

[MySQL]

Description = ODBC for MySQL

Driver = /usr/lib64/libmyodbc5.so

Setup = /usr/lib64/unixODBC/libodbcmyS.so

UsageCount = 5

[MySQL ODBC 515 Driver]

Description = ODBC 5.515 for MySQL

DRIVER = /usr/lib64/libmyodbc5-5.1.5.so

SETUP = /usr/lib64/unixODBC/libodbcmyS.so

UsageCount = 3

Please note that I had to make up this configuration myself, I did a find for libmyodbc* and found these two .so files, thus set up a driver for each of them. A search for libodbcmyS* yields:

/usr/lib64/unixODBC/libodbcmyS.so.1

/usr/lib64/unixODBC/libodbcmyS.so

/usr/lib64/unixODBC/libodbcmyS.so.1.0.0

So, I don't know what else that configuration could be.

The content of /etc/unixODBC/odbc.ini is:

[target_db]

Driver = MySQL

Server = [servername.com]

Port = 3306

Database = [databasename]

Option = 2

User = [username]

Password = [password]

I've tried different options in "Driver", changing it from MySQL, to MySQL ODBC 515 Driver, to the path to the .so file (eg: /usr/lib64/libmyodbc5.so) and all yield the same result.

I'm running:

odbcinst -i -d -f /etc/unixODBC/odbcinst.ini

Followed by:

odbcinst -i -s -l -f /etc/unixODBC/odbc.ini

Followed by:

odbcinst -s -q

Which prints out the name of my connection, ie [target_db]

Then, I try the connect:

isql -v target_db user password

or just

isql -v target_db

and get the error shown above.

Anyone happen to know what I'm doing wrong here? Thanks a bunch-

EDIT:

Wanted to mention that I'm able to connect to the database from this server using the mysql command line tools.

I installed a local mysql database, and I'm able to connect to this using isql. It seems to be ignoring my odbc.ini file entirely, i have to enter a name with the command, ie isql -v test-database, but it still tries to connect to localhost despite my settings.

I feel as though I've tried everything but will keep at it and will post if i find a solution.

解决方案

You could try to connect using the ip of your server instead of the dns entry on the "Server" line of odbc.ini.. Have you verified the driver is installed with phpinfo()?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值