Locally from the JumpBox
You can access MySQL locally by registering, then SSHing into your JumpBox as the admin user and running the command:
sudo mysql --defaults-file=/etc/mysql/debian.cnf
This will connect you as the 'debian-sys-maint' user, which is ALMOST as good as root. If you truly need to connect as the root MySQL user, get the root password:
# For 1.0 JumpBoxes sudo grep password /etc/mysql/debian.cnf # For 1.1+ JumpBoxes sudo grep root /jumpbox/lib/appdata.yml
and use that password when connecting as follows:
mysql -u root -p
Over the Network
For security reasons, the MySQL server installed on the JumpBox is not accessible from remote machines. These instructions show you how to change this yourself. Please understand that this may be a bad idea if your JumpBox is not on a secure network, so proceed with caution.
Register then SSH into your JumpBox and run the following command to edit the MySQL configuration file:
sudo nano /etc/mysql/my.cnf
Find the "bind-address" line and replace 127.0.0.1 with 0.0.0.0
#bind-address = 127.0.0.1 bind-address = 0.0.0.0
Now restart MySQL, sudo /etc/init.d/mysql restart, and it should be accessible remotely, but before that is useful, we need to grant access to modify a database to a remote user.
In order to do this connect to MySQL locally using the following command in the shell:
sudo mysql --defaults-file=/etc/mysql/debian.cnf
Once you are in MySQL execute the following command:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'desiredpassword';
This will enable a user called 'root' on any remote host (that is what the @'%' means) who uses the password 'desired' to do anything (except GRANT privileges) to any database. For details see the MySQL 5.0 documentation on the GRANT command.
Now you can access MySQL remotely, either using a GUI admin tool or a command line too like mysql:
mysql -h JumpBoxIP -u root -p
Interacting with MySQL
With MySQL configured to listen on the network interface there are now at least three ways to interact with the MySQL server on the JumpBox.
- Command Line Tools - This way is always available to those with registered JumpBoxes and shell access to the JumpBox, using the MySQL command line tools.
- Web Admin Tool - It is possible to install the web based administration tool, phpmyadmin, on your JumpBox, instructions are shown in the Installing PHPMyAdmin FAQ
- GUI Tools - There are a number of GUI tools for administering MySQL. They will typically require that you have made MySQL accessible remotely as shown above. MySQL has GUI tools available for free download and SQL Pro is a great open source client for Mac.