7/07/2008

Install MySql GUI tools (MySql Administrator and Query Browser)

The easiest way to install them on Ubuntu is to use Ubuntu package manager, either command line:

sudo apt-get install mysql-admin
sudo apt-get install mysql-query-browser
Or inside System | Administration | Synaptic Package Manager, search for "mysql-admin" and "mysql-query", mark them for install, and then apply the changes.

After installation is complete, open a terminal and run command mysql-admin or mysql-query-browser. If running them in an existing terminal, you may need to run rehash command first to include the new tools in PATH. Everything should just work.

I also tried installing the generic Linux tar bundle for MySql GUI tools, but had a couple of problems:

1. Download the generic Linux bundle (mysql-gui-tools-5.0r12-linux-i386.tar.gz) from http://dev.mysql.com/downloads/gui-tools/5.0.html . The bundle for Linux includes MySql Administrator and Query Browser (MySQL Migration Toolkit is currently only in Windows bundle).

2. To install the tools, just extract the archive. There are instructions at http://dev.mysql.com/doc/administrator/en/install-generic-tarball.html . Basically, execute this command to expand the downloaded file on Desktop to /opt:
cd /opt
sudo tar xzf $HOME/Desktop/mysql-gui-tools-5.0r12-linux-i386.tar.gz
3. To run MySql Administrator and Query Browser:
/opt/mysql-gui-tools-5.0/mysql-administrator
/opt/mysql-gui-tools-5.0/mysql-query-browser
You may also want to copy/move/link MySQLAdministrator.desktop and MySQLQueryBrowser.desktop to $HOME/Desktop, so you can double-click to launch them.

When running Query Browser, I ran into this issue: mysql-query-browser is freezing every way i try to pick, or click, a scheme. I tried removing everything under $HOME/.mysqlgui/ but still the same.

It's possible to install to directories other than /opt, but it may cause various troubles. I'd suggest stick to the default install directory /opt. I first tried to install under $HOME/mysql directory, to group all mysql-related programs under one umbrella. But I had this error when running ./mysql-administrator --update-paths:
(mysql-administrator-bin:11880): libglade-WARNING **: could not find glade file '/home/me/mysql/share/mysql-gui/common/preferences.glade'
terminate called after throwing an instance of 'MGGladeXML::Error'
Aborted
I then chose to install directly under $HOME so that mysql-gui-tools-5.0/ and mysql/ are at the same level. I also ran mysql-administrator --update-paths to update the paths. I was able to run MySql Administrator, but the GUI fonts are sort of blurred, probably because some GTK library cannot be found. This problem was gone once I changed to the default install location /opt/mysql-gui-tools-5.0.

In addition, the update-paths command doesn't seem to update path for Query Browser, since MySQLQueryBrowser.desktop file still has paths under /opt.

Configure MySql in NetBeans

NetBeans 6.1 has an interface to manage MySql, including start and stop MySql database server, connect/disconnect from databases, launch external MySql admin tool, execute queries, etc. Here are steps to configure MySql management inside NetBeans:

1. Create a wrapper script for mysqld_safe. The reason is that mysqld start script assumes the user is running the script from mysql base directory. An attempt to start mysqld from mysql/bin directory results in the following error:

/home/me/mysql/bin > ./mysqld_safe
./mysqld_safe: 199: my_print_defaults: not found
./mysqld_safe: 204: my_print_defaults: not found
The file /usr/local/mysql/bin/mysqld doesn't exist or is not executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/mysqld_safe.
See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more information
So I created script /home/me/mysql/bin/mymysqld_safe, which can be called by NetBeans:
#! /bin/sh
cd /home/me/mysql/
./bin/mysqld_safe &
I had also tried changing mysqld_safe script to replace the hardcoded ./bin/ with `dirname $0`, but it caused other errors. So I figured the best option is to use a wrapper without touching mysql files.

2. Go to NetBeans Window | Services tab, and right-click DataBases node. Choose Properties.
Basic properties:
Server host name: localhost
Server port number: 3306
Administrator user name: root
Administrator password:

Admin properties:
Path/URL to admin tool: /usr/bin/mysql-admin
Path to start command: /home/me/mysql/bin/mymysqld_safe
Path to stop command: /home/me/mysql/bin/mysqladmin
Arguments to stop command: -u root shutdown

How to install MySql admin tool and Query Browser is posted in the previous post Install MySql GUI tools (MySql Administrator and Query Browser) .