Friday, March 18, 2011

Connect to MySQL database from LibreOffice Base on Ubuntu

LibreOffice's Base program can provide a quick easy way to access a MySQL database and write some reports against data.  The following outlines how to easily setup LibreOffice Base to connect to MySQL.  It assumes that you already have LibreOffice Base installed.  It works just as easily for OpenOffice Base.

First we need to install the JDBC driver for MySQL
sudo apt-get install libmysql-java
Next open up any LibreOffice program and then click on Tools->Options.  Expand LibreOffice and then click on Java.  Click on the Class Path button on the right followed by Add Archive.  Browse to /usr/share/java/mysql-connector-java.jar  Click Ok and choose to restart LibreOffice.

Now open LibreOffice Base and choose to Connect to an existing database.  In the drop-down menu choose MySQL, and connect using JDBC.  Click on the Test class button to make sure the JDBC driver loads successfully.  If it doesn't, then check that you followed the previous steps properly.  If it does load then simply enter the settings as it relates to your MySQL database.

If you get the JDBC driver to load properly, but you cannot connect to your MySQL database, then I would recommend installing the mysql client and making sure you can connect from the MySQL client first.  If the JDBC driver loads properly, and you can connect to your database with the MySQL database, then you should not have any problem connecting with LibreOffice.

6 comments:

  1. Many thanks! Very useful, been trying to connect to MySQL for an hour or so!

    ReplyDelete
  2. Thanks, this worked perfectly. I couldn't connect to mysql from LibreOffice base after switching to LOB from OpenOffice.org Base. I was going to install the connectors from the Oracle mysql site, when I saw your post and tried that instead. Works fine.

    ReplyDelete
  3. Molte grazie, non sapevo proprio come connettermi al DB mysql con LibreOffice

    ReplyDelete
  4. Thanks for taking the time to put this page up. Very useful and easy to use!

    ReplyDelete
  5. A thank you from Neoselen, in Ubuntu (prime OS, dual boot witha W7 in case of playing some other games like W.o.w)

    ReplyDelete