Setting up with MySQL

MySQL is an Oracle Corporation product, was previously a Sun Microsystems one, and a MySQL Abs one before that. It is one of the most famous open-source relational database management systems, RDBMS, in the world. The code is available under the GNU license.

It is used by many companies, such as Nokia, Facebook, and Google, for its robustness and for being free for use.

At some point, Sun distributed installation packages of NetBeans bundled with MySQL, which is not the case anymore, but MySQL is still integrated and easily configured from it.

Getting ready

For this recipe we will use MySQL version 5.4.1 and MySQL GUI Tools.

Installation and configuration of MySQL Server and components onto the Operating System is beyond the scope of this recipe. What will be learned here is how to configure MySQL with NetBeans so that the integration between database and IDE can be achieved.

In this recipe, we assume that the Database is installed locally and the password is chosen by the user.

Note

For more information and downloads, visit the following link for the database:

http://www.mysql.com/downloads/mysql/

And for workbench visit http://www.mysql.com/downloads/workbench/.

How to do it...

With the IDE open:

  1. Navigate to the Services window and expand the Databases section.
  2. Right-click on Databases and select Register MySQL Server....
    How to do it...

    A MySQL Server Properties window is shown.

  3. Under Basic Properties, the IDE, by default, enters localhost as Server Host Name and 3306 as Server Port Number.
  4. Then just add the Administrator User Name and Administrator Password that you configured during MySQL installation.

The MySQL Server Properties window should look more or less like this:

How to do it...

Then click on the Admin Properties tab. Under Path/URL to admin tool, enter the folder for the Administration tool and also the paths to start and stop commands for MySQL under shell or command prompt.

Then click OK.

An example of configured Admin Properties:

How to do it...

A MySQL node is added to the Database section of the Services window.

How it works...

The Basic Properties tab is the minimum information required to a connect to MySQL server this is all that is needed for the connection to work. The information required to better control the MySQL Server is on the Admin Properties tab. The Start and Stop commands and path for MySQL-related tools are also included in the submenu, which can be accessed by right-clicking.

Upon registration, there are two ways of checking whether MySQL Server is connected or not:

  • If the MySQL Server node can be expanded, it means that it is connected
  • The same node shows a Not Connected string

Once the node is expanded, the IDE will show the databases included in your server. Note that the number of databases included might differ from system to system, and if the MySQL Server already contains other databases.

There's more...

Want to Create Databases and Run the Administration tool from within the IDE? You've come to the right place.

Creating Databases

To create databases on a registered MySQL Server instance simply:

  1. Right-click on the MySQL Server at localhost node and select Create Database....
  2. A Create MySQL Database window will ask for the New Database Name. Enter mysqltest and press OK.
  3. The Databases subsection will look like this:
Creating Databases

Running the Administration Tool

To run the MySQL Administration Tool, it is necessary to configure the IDE with the correct path. If unsure how to do this, refer to the beginning of this recipe, under MySQL Server Properties, in the Admin properties tab.

With the configuration in place:

  1. Navigate to the Services window and expand the Databases node.
  2. Then right-click on MySQL Server at localhost.
  3. Select Run Administration tool.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.158.21