MySQL Database Server

This document covers the use of the MySQL database server running on igor, the Department of Computing Linux server. The MySQL server is available for use by all students in the Department of Computing.

Your MySQL Account

You can create your own MySQL account by clicking on the "MySQL Account Status" link under "Applications and Utilities" on the Department of Computing Intranet. This will display a page showing the current status of your MySQL account (active or inactive). On this page, you can create your MySQL account and also set your MySQL password, which is particularly useful if you have forgotten your MySQL password. Note that your username for MySQL will be the same as your normal Goldsmiths network username, but your MySQL password is completely separate from your Goldsmiths network password. You can also change your MySQL password from within MySQL (see below).

Connecting to MySQL

Users of the PostgreSQL database system will probably be familiar with the psql command-line utility which is used to connect to the PostgreSQL server and run SQL queries and updates. The equivalent MySQL utility is called mysql and it works in basically the same way, though the options and commands are slightly different. You can see the online help for the mysql utility by typing man mysql at the command-line prompt on igor.

The following shows how user ma007xyz would connect to the MySQL server using mysql:

  mysql -h igor -u ma007xyz -p

This command tells mysql to connect to the MySQL server on host igor (-h igor) as user ma007xyz (-u ma007xyz) and to prompt for a password (-p). As indicated above, if this was the first time this user had connected, their password would be blank and they would just press Enter when prompted for a password.

Once connected to the MySQL server, you can create databases and tables and run SQL queries and updates on them. If you wish to connect to a specific database when you start mysql, you can specify the database name at the end of the mysql command-line. For example, to connect to their default initial database (see Creating Databases below), user ma007xyz would type:

  mysql -h igor -u ma007xyz -p ma007xyz

Changing Your Password

Once you have connected to the MySQL server for the first time, you should set a password for your account to make it more secure. To change your password, type the following at the mysql prompt:

  SET PASSWORD=PASSWORD('new_password');

This will set your password to new_password (you should replace new_password with the password that you want to set).

Creating Databases

When your MySQL account is first created, a default initial database is also created for you using your username as the database name. For example, user ma007xyz will initially own a single empty database called ma007xyz.

You can create as many additional databases as you wish, using your username followed by an underscore as a prefix to the database name. For example, user ma007xyz might create additional databases called

 ma007xyz_ecommerce
and
 ma007xyz_webdesign

Further Information

The MySQL Reference Manual provides a comprehensive guide to the specific version of MySQL installed on the Department of Computing server.

For more general information about MySQL, visit the MySQL website.


Last modified on 9th March 2003 by Eamonn Martin