- 1 MySQL, ODBC with OpenOffice Setup on LocalHost
- 2 MySQL, ODBC with OpenOffice Setup on the Remote Server
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 # pacman -Sy myodbc
Configure Your ini Files
Configure your "odbc.ini", ".odbc.ini", and "odbcinst.ini" file. Startinig with odbcinst.ini, Su to root and set up your /etc/odbcinst.ini file as follows
[MySQL] Description = ODBC Driver for MySQL Driver = /usr/lib/libmyodbc.so Setup = /usr/lib/libodbcmyS.so FileUsage = 1
Next set up your "odbc.ini" and ".odbc.ini" file. It should be pointed out here that the ".odbc.ini" file is just like the "odbc.ini" file except that it is a file that gets saved in the user's home dir (i.e a hidden file).
[MySQL-test] Description = MySQL database test Driver = MySQL Server = localhost atabase = 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
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
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
If the connection is established, you will see
+---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
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 /etc/my.cnf so that port 3306 will be running to do this comment out skip-networking and also add bind-address = your IP
#skip-networking bind-address =192.168.0.100
Next add a line in "hosts.allow"
Although it is recommended to do something like mysql:192.168.0.101 or whatever your client machine would be.
Verify Port 3360 is Listening
restart with the command "/etc/rc.d/mysqld restart" and then check to see that port 3306 is listening on the server
Permissions on MySQL for Remote Connection
Next it is neccesary to give permissions on the server so that MySQL will allow a remote connection.
mysql -u "username" -p mysql> CREATE DATABASE foo; mysql> GRANT ALL ON foo.* TO username@'192.168.0.101' IDENTIFIED BY 'PASSWORD';
3) grant permission to individual IP in mysql http://www.cyberciti.biz/nixcraft/vivek/blogger/2006/03/how-do-i-enable-remote-access-to-mysql.php Grant access to new database If you want to add new database called foo for user bar and remote IP 184.108.40.206 then you need to type following commands at mysql> prompt:
mysql> CREATE DATABASE foo; mysql> GRANT ALL ON foo.* TO bar@'220.127.116.11' IDENTIFIED BY 'PASSWORD'; Grant access to existing database Let us assume that you are always making connection from remote IP called 18.104.22.168 for database called webdb for user webadmin then you need to grant access to this IP address. At mysql> prompt type following command for existing database:
mysql> update db set Host='22.214.171.124' where Db='webdb'; mysql> update user set Host='126.96.36.199' where user='webadmin';
From remote system type command:
$ mysql -u webadmin –h 188.8.131.52 –p You can also use telnet to connect to port 3306 for testing purpose:
$ telnet 184.108.40.206 3306
____________________________________________________ [MySQL-test] Description = MySQL database test Driver = MySQL Server = 192.168.0.2 Trace = Off TraceFile = stderr Database =foo Port = 3306 USER = adowns Password = boston Socket = /tmp/mysql.sock Option = Stmt =