Difference between revisions of "Odbc"

From ArchWiki
Jump to: navigation, search
m (more detailed information about the configuration files)
(34 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:Networking (English)]]
#REDIRECT [[Open Database Connectivity]]
[[Category:HOWTOs (English)]]
=MySQL, ODBC with OpenOffice Setup on LocalHost=
This document shows how to set up ODBC in Arch, first to access you database on your localhost and then extends the steps to configure MySQL to allow remote access through ODBC.
==Packages To Install==
Start by installing the unixodbc and myodbc
# pacman -Sy unixodbc myodbc
==Configure the ini Files==
Configure the "odbc.ini" and "odbcinst.ini" file.
Starting with odbcinst.ini, which lists all installed drivers. Su to root and set up your /etc/odbcinst.ini file as follows
Description    = ODBC Driver for MySQL
Driver          = /usr/lib/libmyodbc.so
Setup          = /usr/lib/libodbcmyS.so
FileUsage      = 1
Next set up your data sources in "/etc/odbc.ini" (system wide) or "~/.odbc" (current user). If a data source is defined in both of these files, the one in your home directory take precedence.
Description    = MySQL database test
Driver          = MySQL
Server          = localhost
Database       = test
Port            = 3306
Socket          = /tmp/mysql.sock
Option          =
Stmt            =
==Create A Symbolic Link==
Next we need to create a symlink for libmyodbc.so. To do this we need to go to /usr/lib/myodbc3-3.51.12.so or
whatever the version of the module is and set up a symlink to libmyodbc.so
ln -s /usr/lib/libmyodbc3-3.51.12.so ./libmyodbc.so
==Renamed Modules==
OK, for this step I cheap-skated it a little and simply copy these files to agree with version of ODBC that Arch
was looking for.
cp libssl.so.0.9.8 libssl.so.0.9.7
cp libcrypto.so.0.9.8 libcrypto.so.0.9.7
==Create A Test Datbase==
On my machine I run phpmyadmin so I already had a test database to use. If you don't have a test database then
create one in MySQL.
==Testing the ODBC==
To test the ODBC connection
isql MySQL-test
If the connection is established, you will see
| Connected!                            |
|                                      |
| sql-statement                        |
| help [tablename]                     |
| quit                                  |
|                                      |
If you have a problem connecting then check the error message by running
isql MySQL-test -v
==A Couple Useful Websites==
This website got me going on ODBC with MySQL but left out some things that were necessary for me
to get isql up and running. However this might be a good reference for the OpenOffice part.
To work around error messages this URL proved helpful so here it is as well.
=MySQL, ODBC with OpenOffice Setup on the Remote Server=
==Edit odbc.ini==
From the Client side it is neccessary to edit the odbc.ini and the .odbc.ini files slightly. Here is the odbc.ini that I used to login.
Description    = MySQL database test
Driver          = MySQL
Server          =
Trace          = Off
TraceFile      = stderr
Database        = test
Port            = 3306
USER            = username
Password        = secretpassword
Socket          = /tmp/mysql.sock
Option          =
Stmt            =
==Edit my.cnf==
Edit /etc/my.cnf so that port 3306 will be running to do this comment out skip-networking and also add
bind-address = your IP
bind-address =
==Edit hosts.allow==
Next add a line in "hosts.allow"
It is recommended to do something like mysql: or whatever your client
machine would be.
==Verify Port 3360 is Listening==
restart the mysql server with the command "/etc/rc.d/mysqld restart" and then check to see that port 3306 is listening
on the server
netstat -ant
If port 3306 is open, you'll see the following
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address          Foreign Address        State
tcp        0      0*              LISTEN
==Permissions on MySQL for Remote Connection==
Next it is neccesary to give permissions on the server so that MySQL will allow a remote connection.
Type "mysql -u "username" -p" and log into you MySQL
mysql> CREATE DATABASE test;
mysql> GRANT ALL ON test.* TO username@'' IDENTIFIED BY 'PASSWORD';
Here was a helpful URL for this step.
==Testing the ODBC==
run the "isql MySQL-test" command and you should be able to log into your server.
The main error message that took a while for me to figure out was the error message "Lost connection to MySQL server during query". This was being driven from the hosts.allow not being added.
Also from the client you can run the following command to verify that port 3306 is open
telnet 3306
Good luck and happy computing now that you can get OpenOffice to connect to you datbases.
Alex & HW

Latest revision as of 10:32, 21 February 2015