Setting Up Your Own Web Server on a Windows Machine – Part III (MySQL)

This tutorial will walk you through the installation process of MySQL server under Windows XP. This part of the tutorial requires you to have Apache HTTP server and PHP installed on your local machine. If you haven't done so, you can read the part one of this tutorial to complete Apache installation. Also, you can complete the second part of this tutorial to have PHP installed. We will use Apache version 2.2.4, PHP 5.2.1 and MySQL 5.0.37 for this tutorial.

Downloading MySQL Distribution

We will use the latest version of MySQL. As the time of writing, the latest version is 5.0.37.

Visit MySQL official download page, choose a Windows distribution, depending on type of your processor: Windows or Windows x64. Download the one with the title Without installer, since we are doing manual installation.

Follow the link Pick a mirror and download it from the location which is closest to you. The downloaded file should have name similar to

MySQL download location

After you downloaded the zip package, extract it to anywhere you want. The suggested location is C:\mysql.

Installing MySQL as a Windows Service

Install MySQL as a Windows Service is the most convenient way to start and stop MySQL server. Let's do it.

We need to run mysqld.exe in command prompt. So open command prompt and navigate to MySQL installation folder (typically C:\mysql). Type cd bin to change the current working directory to bin and type the following command:
mysqld --install

You should receive a message that indicates MySQL service is installed successfully (shown in the figure below).

Type net start mysql to start MySQL service.

net start mysql

You should be notified that MySQL service was started successfully.

Install MySQL as a Windows Service

Verifying MySQL Installation

Open command prompt, navigate to the bin directory of MySQL and type mysql test to verify your MySQL installation. If you see mysql> right before your command prompt cursor, your MySQL server is up and running. Type show databases; you should see a list of pre-created databases.

Run MySQL test


If you receive the following error message when you try to start MySQL service, you might need to create an option file under your Windows root:

Error: Could not start the MySQL service on Local Computer. Error 1067: The process terminated unexpectedly

To create an option file, create a new file and save as my.ini under your Windows root directory (type systemroot in the explorer to find out the location of your Windows root directory), and insert the following content:

Change basedir and datadir to their appropriate locations. basedir is the root directory of your MySQL installation, and datadir is the location where your database files reside (the default location is basedir/data).

Enabling MySQL as a PHP Extension

In order to run database driven applications from Apache, you need to enable MySQL from PHP.

To proceed, open PHP configuration file php.ini in a text editor, navigate to the line ;extension=php_mysql.dll, uncomment it by remove the comma in front of the line.

enable MySQL extension

Restart Apache service through Apache Service Monitor.

That's it. You are now ready to run many exciting web applications that require a database.


  1. First, make sure your PHP's extenstion path is configured correctly
  2. If your receive the following error:
    Error: PHP Startup: Unable to load dynamic library 'PHP_ROOT\ext\php_mysql.dll' - The sepcified module could not be found.
    Make sure php_mysql.dll is visible by Apache. Refer to Enable/Disable Extensions in PHP and PHP official documentation for more information.

Installing phpMyAdmin (Optional)

You certainly can run any SQL queries and data definition statements through command prompt, but it is rather inconvenient. phpMyAdmin can simplify SQL administrative tasks with ease. If you have no idea what phpMyAdmin is, you can find out more at phpMyAdmin official wiki.

Downloading and Installing

Grab a copy of phpMyAdmin distribution from We will use phpMyAdmin version

Extract the downloaded package to Apache's Document Root. If you chose the default root directory during the installation, the Document Root is located at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs. Rename the extracted folder to phpMyAdmin.

phpMyAdmin Folder Name

Restart Apache using Apache Service Monitor.

You can now access phpMyAdmin from http://localhost/phpMyAdmin/. Feel free to create some test databases/tables and run SQL queries.


Congratulations! You are ready to run many exciting database driven web applications on your personal computer. Check them out:

And much more!

Return to tutorial home

4 Comments Setting Up Your Own Web Server on a Windows Machine – Part III (MySQL)

  1. Cuong

    In this case, you may need to provide an username, try

    If that doesn't work, you need to supply a password:

Comments are closed.