Using MySQL

After downloading the files unzip them into a directory. These instructions assume the directory is called MySQL.

Download and unzip these files into the same directory. There should be 7 files, 3 for starting and stopping the mySQL server, and 4 for creating the database. Note that the files should be in the MySQL directory, NOT inside a subdirectory.

Execute mySQLstartup.bat (double-click should work). You should see a console window (also called DOS prompt) indicating the server (DBMS) is ready. This may take a few minutes.

Execute mySQLsql.bat. You should see another console window, with a mysql prompt.

At the mysql prompt, the command \. filename (slash period) will read a file and execute the SQL commands. The first time you execute mySQLsql.bat, you should execute the file SQLInit. This will set the password for the root user of your database. You can change the password either by editing this file and executing it again, or by executing the set password command yourself. It will also create a database to be used for your assignments.

Every time (after this) that you start the command console, you will have to provide the password in order to connect to the DBMS. Also, you will have to tell the DBMS which database you wish to use. Throughout the semester, we will use different databases, but the first several assignments will all use the same one. You may wish to modify the mySQLsql.bat program to add a parameter to tell the DBMS which database to use. You can always change to a different database at the mysql prompt. The command to select the database for use is

use dbname

Now load the tables into the database. There are three files to create the database for you, SQLCustomers, SQLstockprices and SQLstockorders. They should be loaded in this order.

Your database is ready for assignment 1! Note that if you do not re-install the DBMS, the database will be ready everytime you execute mySQLstartup.

When you are finished, exit the command console with the command

quit

Terminate the DBMS by executing the mySQLshutdown.bat program. You will be prompted for the root password before the DBMS quits. This is an important step for our later assignments.