[unixODBC-support] FIXED - Re: Segmentation fault when using isql

mysql_04 at yahoo.com mysql_04 at yahoo.com
Sun Aug 29 21:20:59 BST 2004


First of all, many thanks to Nick Gorham for his patience and help.

I now have a fix for multiple problems in setting up unixODBC so that I 
can connect OOo to MySQL on my local machine. 

Initially following the McCreesh how-to, I reached the point of testing 
the ODBC software, but I receive a segmentation fault when running 
isql.  The following is a procedure that worked for me to solve multiple 
problems.  Detailed explanation follows the summary.

Dan

===============================================
Summary:

1. copy the unixODBC*.tar.gz file to the /usr/local directory. 
2. gunzip unixODBC*.tar.gz
3. tar xvf unixODBC*.tar

Compile the source using:
./configure --enable-stats=no --enable-gui=no --sysconfdir=/etc
make
make install

Now, install MyODBC:
rpm -ivh --nodeps MyODBC-3.51.07-1.i586.rpm

Edit the /etc/odbc.ini and etc/obdcinst,ini files and also copy them to 
/home/<user>.  Rename the /home/<user>/odbc.ini file to 
/home/<user>/.odbc.ini so that it is a hidden file.

    odbc.ini:

    [MySQL-test]
    Description = MySQL database test
    Driver = MySQL
    Server = localhost
    Database = test
    Port = 3306
    Socket = /var/lib/mysql/mysql.sock
    Option =
    Stmt =

    odbcinst.ini:

    # Example driver definitinions
    #
    #
   
    # Included in the unixODBC package
    [PostgreSQL]
    Description = ODBC for PostgreSQL
    Driver = /usr/lib/libodbcpsql.so
    Setup = /usr/lib/libodbcpsqlS.so
    FileUsage = 1

    # From the MyODBC package
    [MySQL]
    Description = ODBC for MySQL
    Driver = /usr/lib/libmyodbc.so
    Setup = /usr/lib/libodbcmyS.so
    FileUsage = 1

Make a link in /usr/lib to libmyodbc3-3.51.07.so and name it libmyodbc.so

Now try:
isql -v MYSQL-test

I received:

[user at localhost user]$ isql -v MYSQL-test
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

end of summary
===============================================================

Detailed explanations:

System notes:

Compaq Presario 700Mhz, 256Mb ram
Redhat v8
the local compiler is gcc-c++ 3.2-7, glibc is 2.3.2-4.80.8
unixODBC-2.2.9.tar.gz from the unixODBC site
MyODBC-3.51.07-1 from the MySQL site

Instructions:

1. copy the unixODBC*.tar.gz file to the /usr/local directory.  When 
unzipped & installed, the files will be under the local directory.  I 
want that local directory to be /usr/local.  YMMV.
2. gunzip unixODBC*.tar.gz
3. tar xvf unixODBC*.tar

Doing so will create a unixODBC directory with all source files inside.

Compile the source using:
./configure --enable-stats=no --enable-gui=no --sysconfdir=/etc
make
make install

Compilation notes:
./configure --enable-stats=no --enable-gui=no --sysconfdir=/etc

    --enable-stats=no  is an attempt to correct the segmentation fault.  
This is the original error message from isql:
         "
         [dan at localhost dan]$ isql -v MySQL-test
          Segmentation fault
         [dan at localhost dan]$
     "

    --enable-gui=no  provides no GUIs, is used when ./configure can't 
find the X includes.  This is the original error message:
         "
         Error msg:
         checking for X... configure: error: Can't find X includes. 
Please check your installation and add the correct paths!
         "
    --sysconfdir=/etc  will build with the ini files in /etc. I don't 
think this made any difference.

Now, install MyODBC:

rpm -ivh --nodeps MyODBC-3.51.07-1.i586.rpm
    --nodeps  avoids aborting because rpm can't find libmyodbc that 
*does* exist in /usr/lib.  You can check to make sure... 

    The MyODBC error message was:
    "
    [root at localhost MySQL_Connector_ODBC]# rpm -ivh 
MyODBC-3.51.07-1.i586.rpm
    error: Failed dependencies:
    libodbcinst.so.1 is needed by MyODBC-3.51.07-1
    Suggested resolutions:
    unixODBC-2.2.2-3.i386.rpm
    [root at localhost MySQL_Connector_ODBC]#
    "

The odbc.ini and odbcinst.ini files exist in /etc and must be modified.  
(Note:  following the McCreesh document will not always be sufficient.  
Note the "Socket = " line below in the odbc.ini file.  It is blank in 
the McCreesh document, but I had to add the path 
/var/lib/mysql/mysql.sock and copy the file to the /home/<user> 
directory as a hidden file to make isql work.)

    odbc.ini:

    [MySQL-test]
    Description = MySQL database test
    Driver = MySQL
    Server = localhost
    Database = test
    Port = 3306
    Socket = /var/lib/mysql/mysql.sock
    Option =
    Stmt =

    odbcinst.ini:

    # Example driver definitinions
    #
    #
   
    # Included in the unixODBC package
    [PostgreSQL]
    Description = ODBC for PostgreSQL
    Driver = /usr/lib/libodbcpsql.so
    Setup = /usr/lib/libodbcpsqlS.so
    FileUsage = 1

    # From the MyODBC package
    [MySQL]
    Description = ODBC for MySQL
    Driver = /usr/lib/libmyodbc.so
    Setup = /usr/lib/libodbcmyS.so
    FileUsage = 1


When isql won't work because it can't find the library, go make a link 
in /usr/lib to libmyodbc3-3.51.07.so and name it libmyodbc.so

    The isql error message was:

    [danf11 at localhost danf11]$ isql -v MySQL-test
    [01000][unixODBC][Driver Manager]Can't open lib 
'/usr/lib/libmyodbc.so' : /usr/lib/libmyodbc.so: cannot open shared 
object file: No such file or directory
    [ISQL]ERROR: Could not SQLConnect

Then, isql won't like the socket...

    [root at localhost bin]# /usr/local/bin/isql -v MYSQL-test
    [08S01][unixODBC][MySQL][ODBC 3.51 Driver]Can't connect to local 
MySQL server through socket '/tmp/mysql.sock' (2)
    [ISQL]ERROR: Could not SQLConnect
    [root at localhost bin]#

There is no file named /tmp/mysql.sock.  There does exist 
/var/lib/mysql/mysql.sock, but it is empty, ie, zero bytes.  Evidently 
the zero bytes thing is a non-issue, because I added the path to the 
"Socket = " line in /home/<user>/.odbc.ini.  *Read that again!*  Note 
that /home/<user>/.odbc.ini is a hidden file, denoted by the "." 
preceding odbc.ini.  If it is not a hidden file, isql still won't work.

end of details
===============================================================




More information about the unixODBC-support mailing list