Tracked by Issue 127539
We recently moved Java DB functionality to a node under Databases. This spec proposes creating a new node for MySQL that also goes under Databases.
This node does not appear by default. It will appear only if we detect a running MySQL server on the local machine at the default port.
The user will also be able to manually register MySQL it is running on the non-standard port, if it's installed but currently not running, or if it is running on a different machine.
The top-level actions would look like this:
Databases
MySQL -------------------------
| Create Database... |
| Start |
| Stop |
| Connect |
| Delete |
| Run Administration Tool |
| Properties... |
-------------------------
Under the MySQL node will be a list of databases available from this server.
Databases
MySQL
sample
sakila
vir
This database list is automatically refreshed. So for example if you create or drop a database through the Create Database or Delete actions, of if you do this from the SQL editor or even an external tool, the list of databases will be automatically refreshed.
Each database node will have the following actions
These actions are described in more detail below under "Database Actions"
If we do not auto-detect and register the MySQL node, the user can manually register it. There will be a new action under Databases to register the server
Databases
-------------------------
| New Connection... |
| Register MySQL Server |
|-----------------------|
| Enable Debug |
| Disable Debug |
-------------------------
This will bring up the MySQL Properties dialog (see below), and once this is filled in, the MySQL node will appear under the Databases node.
If the MySQL node is already registered, then this action is not available.
The MySQL Node has the name MySQL Server at {host}:{port} [user]", e.g.
MySQL Server at localhost:3309 [root]
If we are currently disconnected from the server, the name also includes the tag "(not connected)", e.g.
MySQL Server at localhost:3309 [root] (not connected)
If we are in the process of connecting to the server, the name includes the tab "(connecting)"
This section describes each of the top-level actions for the MySQL node in more detail
This action brings up a dialog for creating a database, including sample databases
The dialogs for creating a database are described in this separate UI spec.
Database servers are often set up as a service which are managed automatically by the operating system, and which generally, once they're set up, don't need to be regularly stopped and started.
However, in some environments the server may be local to the current user and not installed as a service. In this scenario, it is valuable to provide start/stop functionality from within the IDE.
If the user chooses this action and no start or stop command is set, then they are prompted to set the command:
Output will be sent to an output window for these actions.
"Start" will be disabled if the server is already running and "Stop" will be disabled if the server is not running.
This action removes the MySQL node. It also marks the node as removed, so that next time the user starts up NetBeans we will not auto-register the node again. The user will need to manually register the node using Databases->Register MySQL Server
A confirmation dialog will be brought up to confirm the user wants to delete the node:
------------------------------------------------------------------- | Are you sure you want to delete MySQL Server? | | | | [OK] [Cancel] | -------------------------------------------------------------------
This action brings up the administration tool that is registered with the runtime.
The provider either invokes the admin tool as a separate system process, or if it is a web-based tool, brings up the provided URL in the default browser.
If the administer command has not been set, then when the user picks the action, they are prompted to set the path to the command.
This action brings up a dialog that allows the user to configure important settings for the server. There are two tabs, one for basic settings and one for setting command paths to administrative commands (start, stop, administer)
If the user changes any fields that affect the connection properties to the server, we will attempt to re-connect to the server with the new properties. A dialog is raised if this fails.
If a connection for this database is already registered, we just connect using that connection.
If a connection does not exist, we prompt the user if they want to create a connection, and then bring up the standard create new connection dialog, with the driver and url already filled in correctly. The user can then adjust, set the user and password, and connect.
This action brings up a dialog for deleting a database.
---------------------------------------------------------
| Delete Database |
| |
| Are you sure you want to delete {dbname}? |
| |
| [Cancel] [OK] |
---------------------------------------------------------
If we detect that a connection exists to this database in the DB Explorer, we also delete this connection, as it is no longer valid.
In order to make it as easy as possible to get started with MySQL in NetBeans, we have added the ability to automatically detect a running MySQL server and certain standard installations of MySQL.
If MySQL is running on the local host at the default port of 3306, then we will automatically register the MySQL node in the Services tab and create a default connection to the server.
If the user has a MySQL connection registered with the Database Explorer, we will automatically register the MySQL node using the properties defined on the connection.
If the user adds a MySQL connection, we will automatically register the MySQL node using the properties defined on the connection.
There are a number of installations that we recognize (see list below). If any of these installations are detected on the users's machine, then we will automatically register the MySQL node and set up the properties for the start, stop and administration tool commands.
Note that on UNIX installations, if the installation detected is one we know requires root for start and stop commands, and we detect the UNIX command 'gksu', then we will invoke gksu when running the start and stop commands. This will bring up a dialog from the operating system prompting the user for the root password, and then the command is run as root.
List of Recognized Installations
| Platform | Name | Admin command | Start Command | Stop Command |
|---|---|---|---|---|
| Linux | Standalone installation | <none> | /usr/bin/gksu /etc/init.d/mysql start | /usr/bin/gksu /etc/init.d/mysql stop |
| Linux | XAMPP installation | http://localhost/phpmyadmin | /usr/bin/gksu /opt/lampp/lampp startmysql | /usr/bin/gksu /opt/lampp/lampp stopmysql |
| Macintosh | MAMP installation | http://localhost:8888/MAMP/frame.php?src=%2FphpMyAdmin%2F%3F | /Applications/MAMP/bin/startMysql.sh | /Applications/MAMP/bin/stopMysql.sh |
| Solaris/OpenSolaris | Webstack Installation | <none> | /usr/bin/gksu /usr/bin/svcadm enable svc:/application/database/mysql:version_50 | /usr/bin/gksu /usr/bin/svcadm disable svc:/application/database/mysql:version_50 |
| Windows | Standalone 5.0 | <none> | C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqld-nt.exe | C:/Program Files/MySQL/MySQL Server 5.0/bin/mysql.exe -u root stop |
| Windows | Standalone 5.1 | <none> | C:/Program Files/MySQL/MySQL Server 5.1/bin/mysqld-nt.exe | C:/Program Files/MySQL/MySQL Server 5.1/bin/mysql.exe -u root stop |
I would have liked to have supported Windows XAMPP, but this installation behaves very strangely and I was unable to get it to work properly.
If none of the auto-detection mechanisms are successful, the MySQL node will not be registered. You can, however, manually register the user by choosing the "Register MySQL Server" action under "Databases". This action is only available *if* the MySQL node has not yet been registered.
If the MySQL node is registered, and the user manually deletes it using the "Delete" action, then we will not perform auto-detection again for that user (unless the user removes the user directory). It can be manually registered again if desired.
| connect.jpg | ![]() |
43415 bytes |
| mysql-admin-properties.jpg | ![]() |
79207 bytes |
| mysql-basic-properties.jpg | ![]() |
70742 bytes |
| mysql-set-admin-command.jpg | ![]() |
35467 bytes |
| mysql-set-stop-command.jpg | ![]() |
39957 bytes |
| newdriver.jpg | ![]() |
42285 bytes |