Accessing MySQL Databases from your own Laptop or Workstation

This Note gives information about accessing MySQL from your own Laptop or Workstation with the MySQL Workbench application.

For information about the School's MySQL database server and to learn about your MySQL account and database schema, see

MySQL in the School of Computer Science & Informatics.

Applications for accessing MySQL

MySQL can be accessed from applications and programs on Linux, Windows and Mac OS X platorms. This Note describes accessing MySQL with the MySQL Workbench application.

Obtaining MySQL Software

MySQL is an open source database management system that is freely available for different computing platforms.

You can obtain MySQL Workbench and other MySQL software for different platforms from http://dev.mysql.com/downloads/ but you should also look in your platform's distribution repositories in case there are versions of the software there.

For example,

apt-cache search mysql | grep '^mysql'
lists all packages whose name starts with “mysql” on Ubuntu or or other Debian-based Linux system, and

yum search mysql | grep '^mysql'
lists all packages whose name starts with “mysql” on RPM-based Linux systems.

Download and install MySQL Workbench from MySQL.com or your repository as appropriate.

MySQL Workbench

MySQL Workbench is a modeling tool that lets you design and generate MySQL databases graphically. It can also be used as an interface to execute SQL queries.

MySQL Workbench can be started from the installed executable or menu entry or desktop shortcut as appropriate for your platform.

Using MySQL Workbench

When MySQL Workbench starts, the initial window is divided into three panes.

  • The top left pane is for connections to databases,
  • the lower left pane is for data models,
  • the right side pane is a list of shortcuts to MySQL functions and information.

There is also a menu bar across the top.

To begin with, we need to configure a new connection to the database we want to use.

In the Connections pane click on the after MySQL Connections.

In the setup window, type a name that you want to give to the connection, for example, use your username and the server name, or a description like My Database.

In the Hostname field, enter the server name csmysql.cs.cf.ac.uk.

Select Standard TCP/IP as the Connection Method.

Enter your MySQL username in the Username field and the name of your database in the Schema field.

If you click on Store in Keychain, you will be prompted for your password. Otheriwse MySQL Workbench will prompt for it when you make the connection.

Click on OK, and the an icon for the new connection appears in the workspace.

To open the connection, double-click on the icon.

After obtaining your password, an SQL editor opens in a new tab and connects to the server.

The example here shows a connection to the sample MySQL database.

You cannot log into the sample database from outside the University network. If you want to try these tables, you should create them in your own database. csmysql does allow you to log into your own database from outside.

The left hand pane shows the database schema, including the tables that had been previously created.

To the right is an SQL query pane where you can type SQL commands. The results of executing the commands appear below in the result pane.

To run commands in the SQL query pane, click the execute icon .