无法使用unixodbc,libmyodbc连接到远程mysql服务器 [英] Unable to connect to remote mysql server using unixodbc, libmyodbc

查看:401
本文介绍了无法使用unixodbc,libmyodbc连接到远程mysql服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此有点绿色,我希望我遇到的问题很简单...底部的新信息

我需要连接到远程mysql(Amazon RDS)数据库.

在完成了一些教程之后,我在客户端上安装并配置了unixodbc和libmyodbc,但是当我尝试通过isql连接时,出现错误

[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

关于此错误的最令人困惑的部分是我不是在尝试连接到本地数据库,而是尝试连接到远程数据库.我的客户端上没有mysql.sock文件...这不是问题吗?

我正在感知配置错误,但我不确定是什么错误.

如果我运行odbcinst -j,则输出为:

DRIVERS............: /etc/unixODBC/odbcinst.ini
SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini

/etc/unixODBC/odbcinst.ini的内容是:

[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

请注意,我必须自己完成此配置,我找到了libmyodbc *,并找到了这两个.so文件,因此为每个文件都设置了一个驱动程序.搜索libodbcmyS *会得到:

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

所以,我不知道该配置还可以是什么.

/etc/unixODBC/odbc.ini的内容是:

[target_db]
Driver          = MySQL
Server          = [servername.com]
Port            = 3306
Database        = [databasename]
Option          = 2
User            = [username]
Password        = [password]

我在驱动程序"中尝试了不同的选项,将其从MySQL更改为MySQL ODBC 515驱动程序,然后更改为.so文件的路径(例如:/usr/lib64/libmyodbc5.so),并且都产生相同的结果结果.

我正在跑步:

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

其次:

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

其次:

odbcinst -s -q

打印出我的连接名称,即[target_db]

然后,我尝试连接:

isql -v target_db user password

或者只是

isql -v target_db

并得到上面显示的错误.

有人碰巧知道我在做什么错吗?谢谢一堆

想提一下,我可以使用mysql命令行工具从该服务器连接到数据库.

我安装了本地mysql数据库,并且可以使用isql连接到该数据库.似乎完全忽略了我的odbc.ini文件,我必须使用命令输入一个名称,即isql -v test-database,但是尽管进行了设置,它仍然尝试连接到localhost.

我觉得我已经尽了一切努力,但会坚持下去,并且在找到解决方案时会发帖.

解决方案

您可以尝试使用服务器的ip代替odbc.ini的服务器"行上的dns条目进行连接.是用phpinfo()安装的?

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()?

这篇关于无法使用unixodbc,libmyodbc连接到远程mysql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆