You are not logged in.

#1 2014-10-04 15:16:42

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

[SOLVED] Help configuring unixodbc and myodbc

Hi,
I would like to setup the odbc driver for my mariadb database.

As the version of myodbc in the archive causes a segmentation fault error (there are other posts about it in the forum), and I couldn't use
Arch Rollback Machine, I downloaded the binary for an older version that works from mysql website, extracted the content in my home and created  symbolic links to libmyodbc5a.so and libmyodbc5w.so into /usr/lib.

I configured /etc/odcinst.ini to use /usr/lib/libmyodbc5w.so and created a connection (called mariadb) in ~/.odbc.ini.

Now whenever I try to test the connection using isql -v mariadb I get the following error:

[01000][unixODBC][Driver Manager]Can't open lib '/usr/lib/libmyodbc5.so' : file not found

Of course the file is there and accessible. How can I fix this?

Thanks a lot everybody for the help,
Cheers,
Luca

[note] a step by step list of instructions can be found later in the post: https://bbs.archlinux.org/viewtopic.php … 9#p1464079

Last edited by lucacerone (2014-10-08 22:02:01)

Offline

#2 2014-10-06 08:32:14

dif
Member
From: Stalowa Wola, Poland
Registered: 2009-12-22
Posts: 137

Re: [SOLVED] Help configuring unixodbc and myodbc

Hi,

I have just posted a reply about arch rollback machine at the other thread that you mentioned in the forum.
First of all, try installing myodbc with

# pacman -U <myodbc_you_downloaded>

Don't forget to set "IgnorePkg = myodbc" in /etc/pacman.conf
Hope this helps.

dif

Offline

#3 2014-10-07 23:15:59

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: [SOLVED] Help configuring unixodbc and myodbc

Hi dif thanks for your reply.
Actually what I think it happens is that the environment variables are not set correctly.

I had found  a blog mentioning that the error message is misleading, but I can't find it now.
I mean the library and the symlink are there, the weird thing is that the message says the file is not present.

Anyway in the next days I'll follow your advice on the other post and see if that fixes the problem. Thanks for the help,
Luca

Offline

#4 2014-10-07 23:25:22

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: [SOLVED] Help configuring unixodbc and myodbc

Hi actually I run ldd on the shared library I have installed.
It was missing the reference libodbcinst.so.1, even though I have libodbcinst.so.2 in my /usr/lib dir.
I created a symbolic link: sudo ln -s /usr/lib/libodbcinst.so.2 /usr/lib/libodbcinst.so.1
and now the error message has changed smile

It says: [08S01][unixODBC][MySQL][ODBC 5.2(w) Driver]Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Any idea how I can fix this?
The mysql server works fine.

Thanks again for the help,
Cheers,
Luca

Offline

#5 2014-10-08 10:43:30

dif
Member
From: Stalowa Wola, Poland
Registered: 2009-12-22
Posts: 137

Re: [SOLVED] Help configuring unixodbc and myodbc

Hi.


Your original post suggests that there was a mistake in the installation. So the solution I first suggested should be the first step. If that doesn't help, have a look at this general information about problems connecting to server.

Now, have a look at some of my settings. Perhaps they will point you to a solution. This is working setup.

cat /etc/mysql/my.cnf
-------------------------(this is just an excerpt, not the whole file)----
[client]
port		= 3306
socket		= /run/mysqld/mysqld.sock
[mysqld]
init_connect                = 'SET collation_connection = utf8_general_ci,NAMES utf8'
collation_server            = utf8_general_ci
character_set_client        = utf8
character_set_server        = utf8
datadir         = /home/mdb
tmpdir          = /var/lib/mysqltmp
port		= 3306
socket		= /run/mysqld/mysqld.sock
...
#skip-networking
...

I changed the default data directory to /home/mdb (owned by mysql user). Otherwise, it is a standard setup. My "skip-networking" option is hashed out.

cat /etc/odbcinst.ini
------------------------------
[MySQL]
Description=ODBC Driver for MySQL
Driver=/usr/lib/libmyodbc.so
Setup=/usr/lib/libmyodbc5S.so
FileUsage=1
cat /etc/odbc.ini
------------------------------
[test]
Description     = test
Driver          = MySQL
Server          = localhost
Database        = test
Port            = 3306
Socket          = /var/run/mysqld/mysqld.sock
Option          =
Stmt            =
ls -l /usr/lib/lib{odbc,myodbc}*
------------------------------
/usr/lib/libmyodbc5a.so
/usr/lib/libmyodbc5w.so
/usr/lib/libmyodbc.so -> ./libmyodbc5w.so
/usr/lib/libodbccr.so -> libodbccr.so.2.0.0
/usr/lib/libodbccr.so.2 -> libodbccr.so.2.0.0
/usr/lib/libodbccr.so.2.0.0
/usr/lib/libodbcinst.so -> libodbcinst.so.2.0.0
/usr/lib/libodbcinst.so.2 -> libodbcinst.so.2.0.0
/usr/lib/libodbcinst.so.2.0.0
/usr/lib/libodbc.so -> libodbc.so.2.0.0
/usr/lib/libodbc.so.2 -> libodbc.so.2.0.0
/usr/lib/libodbc.so.2.0.0

I can connect with isql and with LibreOffice base using ODBC.

Best,
dif

Offline

#6 2014-10-08 18:18:31

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: [SOLVED] Help configuring unixodbc and myodbc

Hi dif,
it started all because the myodbc package in the repository causes a segmentation fault.

I then found binaries of older versions (since I didn't have older version to revert to), and installed them.

After a bit of fiddling, I now need to configure it.
One thing I don't have in my path is the libmyodbc5S.so file (and neither do you from what I can see).

However using the right Socket made it work for me smile

Thanks for the help!

I'll try to put a detailed explanation of what I did in case other people have issues!

Cheers,
Luca

Offline

#7 2014-10-08 22:00:09

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: [SOLVED] Help configuring unixodbc and myodbc

For completeness here is the procedure I followed
(I assumed you already have installed mariadb and started the mysqld service)

1. install unixodbc using pacman
2. use odbcinst -j to know the paths that need to be configured, on my laptop this means /etc/odbcinst.ini (this will contain the systemwide settings of the drivers)
and ~/.odbc.ini  (contains the settings of specific connections)
3. download the odbc connector version 5.2.7 binary from mysql website (the 64bit version is here: http://dev.mysql.com/downloads/file.php?id=452109
4. extract the archive in a location of your choice
5. (you need sudo for this) link the content of <myodbc5.2.7_connector_folder>/lib into /usr/lib, for my laptop this is:
sudo ln -s /home/luca/mysql-connector-odbc-5.2.7-linux-glibc2.5-x86-64bit/lib/*.so /usr/lib/
5b. create the link /usr/lib/libmyodbc.so to /usr/lib/libmyodbc5w.so
sudo ln -s /usr/lib/libmyodbc5w.so /usr/lib/libmyodbc.so

6. create the other links:
sudo ln -s /usr/lib/libodbcinst.so.2 /usr/lib/libodbcinst.so.1
sudo ln -s /usr/lib/libodbcinst.so.2 /usr/lib/libodbcinst.so

#eventually use ldd on the libodbc* and libmyodbc* libraries to check whether some library is missing. If you have the library installed, but the naming is wrong
#(e.g. libodbcinst.so.2.0 instead of libodbcinst.so.1)
#you have to create a symbolic link to the installed version with the name required by the library.

7. Check the path of mysql socket in /etc/mysql/my.cnf
the default value is socket  = /run/mysqld/mysqld.sock

8. Create the file /etc/odbcinst.ini and place the following content in it:
# this has to be copied / symlinked in /etc/
[MySQL]
Description = ODBC Driver for MySQL
Driver = /usr/lib/libmyodbc.so
#Setup=/usr/lib/libmyodbc5S.so # i have found this line in several tutorial, but this is actually not required.
FileUsage = 1

9. Create the file ~/.odbc.ini with the following content:
[mariadb] # mariadb is the name of the db connection
Description     = MySQL database test
Driver          = MySQL # this tells unixodb to use the driver set in
User = luca # your mariadb user here...
Password = <your_user_password>
Socket = /run/mysqld/mysqld.sock # this is the value set in /etc/mysql/my.cnf
Server          = localhost # or whatever ip
Port            = 3306 #or whatever port

10. test the connection using
isql -v mariadb

The ODBC driver and connection should now work seamlessly.

Let me know if you have better solutions!!!

Last edited by lucacerone (2014-10-08 22:04:04)

Offline

#8 2014-10-09 09:02:32

dif
Member
From: Stalowa Wola, Poland
Registered: 2009-12-22
Posts: 137

Re: [SOLVED] Help configuring unixodbc and myodbc

My procedure was simpler.
(1) Download the previous package (myodbc 5.2.6-2) from http://seblu.net/a/arm/, and more specifically from here.
(2) Install it with

# pacman -U myodbc-5.2.6-2-i686.pkg.tar.xz

(3) In /etc/pacman.conf, set the IgnorePkg option:

IgnorePkg = myodbc

to prevent updating the package when a system-wide update is made.
That's more or less that.

Other remarks:
- You can have more databases handled by mariadb (mysqld) and definded in odbc.ini (or .odbc.ini), so some people may find using the name "mariadb" for a database a little bit misleading. That's why I used "Test" in my example.
- I think that placing databases in your "/home" (or any separate partition) is safer than keeping them in the system partition. So I changed the default "data directory" as shown in my previous post. I am not a programmer and my knowledge is very limited, so there may be some disadvantages of changing the default data directory that I am not aware of.

Bug.
There is a bug reported and already assigned. https://bugs.archlinux.org/task/42004
For those who read it, please log there and vote. It may speed up fixing the problem.

Last edited by dif (2014-10-09 09:08:40)

Offline

Board footer

Powered by FluxBB