The first step is to download the MySQL Server "Windows Essentials" binaries from the MySQL website at http://dev.mysql.com/downloads/mysql/. At the time this was
written last updated, 5.1.46 was the latest, stable release. The file was named:
mysql-essential-5.1.46-win32.msi. Make sure you save the file to a location on your hard drive where you can locate it.
Run the Installer
MySQL comes packaged as an
.msi file that uses Microsoft's Installer to automate the installation process. Simply double-clicking on the file will begin the installation.
You'll be presented with several screens that guide you through the installation process:
- Welcome - Lets you verify the name and version of the program you're installing.
- Setup Type - Allows you to choose between a typical installation, a complete installation and a custom installation. Choose the "Typical installation".
- Ready to Install the Program - This is your final chance to confirm the installation. After clicking Install, you can sit back and watch the blue bar.
- Competed - Informs you that everything has completed successfully and lets you launch the configuration wizard. Ensure that "Configure the MySQL Server now" option is checked before clicking "Finish". I'd suggest un-checking the "Register the MySQL Server now" check box since, in my opinion, it's a waste of time.
Once the the installation wizard is completed, the configuration wizard begins.
- Welcome - Informs you that you're going to be configuring a MySQL server.
- Select Configuration Type - Gives you the choice between a Detailed and Standard Configuration. Select the "Standard Configuration" option.
- Set the Windows Options - Allows you to decide whether MySQL should run as a Windows Service and if the MySQL directory should be added to the system path. Make sure both options are checked.
- Set the Security Options - Lets you set a root (that's UNIX speak for administrator) password, enable remote root access and create an anonymous account. You are very strongly encouraged to set a root password. If you don't someone can connect to your server, start it, stop it, delete data and probably catch your computer on fire. Consider yourself warned. I'd also suggest leaving the "Enable root access from remote machines" and "Create an Anonymous Account" check boxes unchecked.
- Execute - Gives you a final confirmation before the changes are saved.
Test the MySQL Installation
Open a command prompt and run the following command:
C:\>mysqladmin -u root -p version
You'll be prompted for the root password that you entered during the configuration process. The resulting output should be similar to the following:
Enter password: **************
mysqladmin Ver 8.42 Distrib 5.1.46, for Win32 on ia32
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.1.46-community
Protocol version 10
Connection localhost via TCP/IP
TCP port 3306
Uptime: 1 min 32 sec
Threads: 1 Questions: 10 Slow queries: 0 Opens: 15 Flush tables: 1 Open tab
les: 8 Queries per second avg: 0.108
Create a database
Open the MySQL command line client using -u root to specify the root user and -p to be prompted for a password:
C:\> mysql -u root -p
After entering your password, you should be greeted with a welcome message and prompt that looks something like:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
A quick note before we continue: the semicolon is used to indicate the end of a MySQL query or command. If you forget it MySQL assumes you're entering a multi-line query and you'll be prompted to begin the new line with a
->. This might take a little getting used to.
Now use the following command to create a database named
mysql> CREATE DATABASE drupal;
If the command succeeds you'll get the following response:
Query OK, 1 row affected (0.00 sec)
Add a user
Now, we'll add a new user account named
drupaluser, with a password of
supersecret to the
drupal database we just created. The new user will allow us to log in and work on the database without having the full administrative permissions. That way if we make a mistake it'll only affect this database.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE
TEMPORARY TABLES, LOCK TABLES
TO 'drupaluser'@'localhost' IDENTIFIED BY 'supersecret';
As mentioned before, when you enter a long command like this, the MySQL client may wrap the lines, beginning each with
->. For instance:
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE
-> TEMPORARY TABLES, LOCK TABLES
-> ON drupal.*
-> TO 'drupaluser'@'localhost' IDENTIFIED BY 'supersecret';
Running that command produces the following output. It's worth nothing that even if the command succeeds, it will report that 0 rows were affected.
Query OK, 0 rows affected (0.02 sec)
Once you've added the user, use the quit command to return to the command line.
Test Database and User
You can verify that both the database and user were created successfully with the following command:
C:\>mysql -u drupaluser -p drupal
You should then be greeted by the standard welcome screen. Run the following command to list the tables in the flickr database:
mysql> show tables;
It's a new database so it should be empty:
Empty set (0.02 sec)
Use the quit command to exit the MySQL client.
While you could do all your MySQL server administration from the command line, it is neither fun nor easy. MySQL offers several a free, easy-to-use graphical tools to simply the process. The MySQL Administrator provides a GUI for doing most database management. The MySQL Query Browser makes it easy to create and edit tables, run queries and insert, update and delete records. You can download the software from http://dev.mysql.com/downloads/gui-tools/5.0.html