MySQL Setup and Configuration for CS320

This document describes a step-by-step procedure to install a MySQL 4.1 database server under Windows 2000. If you already have an older version of MySQL installed, you do not have to upgrade it, since we are not going to use any feature that is specific to version 4.1. However, if you do want to upgrade to the latest version, please make sure to uninstall the old version first.

[Download and Installation]

Download MySQL 4.1.7 binary release from the There are several packages under the "Windows downloads" section. It's recommended that you download the one called "Windows Essentials". This package comes in as a single file mysql-4.1.7-essential-win.msi. Once you have the file, you may start the installation by double-clicking on the file, and follow the on-screen instructions. During the installation process, you may leave all the options to default. After the installation is completed, the MySQL configuration wizard will walk you through the configuration of the database server. In the first screen of the configuration wizard, choose Standard Configuration, and in the rest of the configuration process, leave all options to default.

[Post Installation Setup]

Suppose that MySQL is installed under C:\Program Files\MySQL\MySQL Server 4.1, add C:\Program Files\MySQL\MySQL Server 4.1\bin to your PATH environment variable. On Windows 2000 you may need to log off then log in again for the environment variable to take effect.

Open a DOS prompt and execute the command
mysql -u root -p
Type in the root password you supplied during the installation process, and your should be able to see the mysql prompt:
which means that you are now connected to the MySQL database server.

Download the mysql-postinst.sql script. This script performs the following operations:
  1. Modify the mysql user table so that root user can only connect from localhost.
  2. Remove anonymous user's privileges on test databases.
  3. Create a new database cs320stu31.
  4. Create a new user cs320stu31 with password abcd, and grant the user full privileges on the database cs320stu31.
  5. Create a table items with two records in the cs320stu31 database.
You may want to change the user name, db name, and password to match your account information on the CS server, so you can develop your web applications on the local machine, and deploy them on the CS server without any changes.

[Test Run]

If you have set up Tomcat as described in Tomcat Setup and Configuration, you would already have the MySQL JDBC driver mysql-connector-java-3.0.15-ga-bin.jar under %CATALINA_HOME%\shared\lib. Move the file to %CATALINA_HOME%\common\lib - due to some unknown reason, database drivers just don't like to be placed under shared\lib.

Download servlet Modify the source code so the user name, db name, and password match your setup. Compile and run it, and you should see following output:
milk 3.89 2.0
beer 6.99 1.0
Download HelloSQL.jsp. Again, modify user name, db name, and password if necessary. Run the page, and you should see:
name milk
price 3.89
quantity 2
name beer
price 6.99
quantity 1
If you reach here without getting any error, congratulations! You are now ready to suffer the second part of the course.