0

I wonder if someone could help with an issue I can't seem resolve with ODBC for MySQL. I am reasonably new to Linux, so any assistance that can be offered would be helpful.

If it helps, I am running Ubuntu 14.04 x64 on two VirtualBox machines.

I've installed MySQL server on a machine that appears to be working as I can create databases, tables, insert and remove data and run queries without any issue. I've create a database called my_db and a user called db_root within MySQL.

I am now trying to connect to this MySQL server from another machine but I don't seem to be able to get the ODBC connection working. I've looked at a number of online instructions, but they pretty much all give the same set of instructions.

Started off by install unixODBC, unixODBC-dev and libmyodbc. Then edited the /etc/odbcinst.ini file. Mine looks like:-

[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

Then edit the /etc/odbc.ini file. Mine looks like:-

[mysql-connector]
Driver       = MySQL
Description  = ODBC for MySQL
Server       = 192.168.1.1
Port         = 3306
User         = db_root
Password     = password
Database     = my_db
Option       = 3
Socket       =

This is where some instructions change. Some say that there should be a file called mysql.sock or mysqld.sock in the directory /var/lib/mysql and this file should be set as the path for the SOCKET in the odbc.ini file. I have no mysql directory inside /var/lib and searching my machine for mysql.sock and mysqld.sock turns up blank. Some instructions do include the SOCKET field in the odbc.ini file.

All the instructions then say, test your connection with the command something like echo "select 1" | isql -v mysql-connector. I always get the same error of [S1000][unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.1' (111).

I've been searching for days, but can't seem to find anything that might point me in the right direction to resolving this.

0

After a bit more searching, I found the answer was the MySQL setup. In the /etc/mysql/my.cnf, MySQL was only listening on port 3306 for local traffic. This was fixed by removing the line bind-address = 127.0.0.1 in the my.cnf file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.