7/07/2008

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) .

6 comments:

Anonymous said...

I dont undertand. Where is mysqladmin file?

Anonymous said...

I want to know where is mysqladmin file...?

Anonymous said...

mysqladmin is inside the bin folder of MySQL/MYSQL server x.x

Anonymous said...

Search in MySQL/MYSQL server x.x/bin folder!!!

MuthuAnanth said...

I am trying to connect MySQL5.1 in Netbeans7.0.1 RC1 build in Windows 7.

But there connection refused error has been occured.

In Services --> Database --> RegisterMySQLServer
i have given this details.

Basic Prop
----------
HostName : localhost
port : 3306
uname : root
pwd : root

admin prop
----------
Path/url admin tool : C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe

arg :

Path to start cmd : C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld.exe

arg :

path to stop cmd : C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin.exe

arg : -u root -proot stop






But connection refused error is coming. I checked jar file placed in correct place. And using mysql-connector-java-5.1.13-bin.jar.

Anybody knows solution, kindly help me

M.Muthu Ananth
Haiahtum Software

Anonymous said...

Path/url admin tool :C:\Program Files (x86)\MySQL\MySQL Tools for 5.0\MySQLAdministrator.exe

Path to start cmd :C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld.exe


path to stop cmd:C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysql.exe