Installing MySQL Server 5.1 on Windows

MySQL dolphin balancing Windows "ball" logo on its snout

You’ve probably heard of Microsoft’s Web Platform Installer, a free-as-in-beer tool that makes it a snap to install a variety of Microsoft and Open Source web applications and development tools, ranging from “The Usual Suspects”, such as Visual Web Developer, IIS and SQL Server 2008 Express to stuff you might not expect, such as PHP and WordPress. It makes installing these goodies a simple of matter of checking the items you want and clicking the Install button. (While the old way of installing PHP on Windows wasn’t rocket science, it involved enough steps and configuration changes to justify my writing a whole article on the topic in an old developer blog of mine.)

One necessary thing that the Web Platform Installer doesn’t do for you – and I assume it’s because of licensing restrictions of one kind or another – is install MySQL, which many PHP apps, including a number that the Web Platform Installer installs, use. You’ll be told that you need to install MySQL, but it leaves installing it up to you.

Hence this article, where I walk through the steps of installing MySQL Server 5.1 on Windows for a developer machine. Whether you just need PHP and MySQL so that you can experiment with WordPress template designs or are the “I build on Windows, but deploy on Linux” type or are developing for a server setup where IIS is serving both ASP.NET and PHP apps (and yes, IIS does that!), you’re going to want MySQL on your dev box.

Get the Installer

The version we’re interested in is the free-as-in-both-speech-and-beer Community Edition, which is available at the MySQL site. Here are the links to the installers:

Both these options provide you with three different installers. I recommend getting the .msi (Windows Installer) as it’s the lowest-headache option. It’s also the version I use in this walkthrough.

By the way, the screenshots provided in this walkthrough are from my actual installation process on my laptop, which runs the 64-bit edition of Windows 7 Beta, Build 7000 (I’m not installing the Release Candidate until later this week). I’m installing the 64-bit version of MySQL Server 5.1 Community Edition, but whether you’re installing the 32- or 64-bit version on Windows XP, Vista or 7, your experience should be roughly the same.

Here’s what you should see when you launch the installer:


Which Setup Type?

The first choice you have to make is the type of setup you want:


The three choices offered are:

  1. Typical: Installs the basic components for MySQL to the default installation path, C:\Program Files\MySQL\MySQL Server 5.1\, including:
    • The MySQL server
    • The mysql command-line client
    • Other command-line utilities like mysqldump, myisamchk and more.
  2. Complete: Installs all the MySQL components to the default installation path, C:\Program Files\MySQL\MySQL Server 5.1\, including those listed in the Typical setup, plus:
    • Documentation
    • The embedded server library
    • The benchmark suite
    • Support scripts
  3. Custom: Gives you complete control over the components installed and the installation path.

Although the components in the Typical setup will work fine for most web development purposes, I like having the docs handy, so I went with the Complete setup.

Once you’ve selected the setup, you’ll be shown a confirmation window like the one below:


Once MySQL has been installed, you’ll see the window below:


You’ll be given the choice to configure MySQL server, which I recommend. You can do so by leaving the Configure the MySQL Server now checkbox checked and then clicking Finish.

The Configuration Wizard

Here’s the first window of the Configuration Wizard:


Which Configuration?

You’ll be asked which configuration type to use:


The two choices offered are:

  1. Detailed Configuration: Gives you fine-grained control over the configuration process. I’m familiar with the options being offered, so this is the option I chose. If you choose this option, you will have to make some additional choices in the windows that follow.
  2. Standard Configuration: If you’re new to MySQL and need a server configured as a single-user developer machine, this configuration should suit your needs. If you choose this option, you’ll skip the next few steps and go directly to the Root Password window.

Detailed Configuration Options

If you chose to use the Detailed Configuration, you will see the following windows.

Server Type

The first choice in the Detailed Configuration is Server Type:


The three options are:

  1. Developer Machine: This setup assumes that MySQL will be running on a machine used to write applications, where the database will be used for basic developer proofs of concept and simple testing. MySQL will be configured to use minimal system resources. This is the option I selected.
  2. Server Machine: This setup is for server systems where MySQL will be running along with other server applications such as a web server, mail server, FTP server and so on. MySQL will be configured to use a moderate portion of the system resources.
  3. Dedicated MySQL Server Machine: This is for machines that will be running only MySQL. in this configuration, MySQL will be configured to use all available system resources.

Storage Engines

The next choice to make is selecting the storage engines to be used: MyISAM or InnoDB. If you’re not familiar with MySQL, you’re probably asking “What’s the difference between InnoDB and MyISAM?”

Of the two engines, MyISAM is the older of the two, and the default engine. The general consensus is that in most cases, it’s faster than InnoDB for typical CRUD operations. It supports up to around 4 billion rows of data and 64 indexed fields per table. MyISAM uses table-level locking, which means than when a row is being updated, the table is locked and no other operations can update any other rows until the first row is updated and the lock on the table is released.

InnoDB is the newer (and some would say sexier) engine. It’s called “the transactional one”, and it’s built with data integrity in mind. It supports foreign key constraints, meaning that changes to a table (say, “Actors”) that references another table (say, “Movies”) are allowed only if those changes leave both in a valid state. For example, you wouldn’t be able to delete a row from the “Actors” table if it referenced any rows in the “Movies” table (that is, you can’t remove an actor from the database if s/he’s listed as starring in any movies). It also supports row-level locking, which means that so that more than one row can be updated at the same time.

The general guidelines for choosing between MyISAM and InnoDB are as follows:

  • Will your use of the database be mostly reading? That is, will you be doing mostly select operations and few insert, update and delete operations? Then you want MyISAM.
  • Will your use of the database involve at least as many writes as reads, if not more? That is, will you be doing as many insert, update and delete operations as select operations? Then you want InnoDB.
  • Do you need full-text search? You want MyISAM.
  • Do you need to conserve disk space and RAM? You want MyISAM.
  • Does the idea of using a non-SQL Server database irk you? You might feel better going with InnoDB, since it has the row-level locking, transaction safety and generally more “relational” feel.

Keep in mind that when adding a table to a MySQL database, you can specify which engine it uses. Lately, I’ve been in the habit of specifying InnoDB for most tables except those on which I want to provide full-text search; for those, I’ve specified MyISAM. (For more on specifying engines when creating tables, see MySQL’s page on the create table command.)

Now that I’ve done a quick review of MyISAM and InnoDB, let’s look at the storage engine choices that the Configuration Wizard offers.


The three choices are:

  1. Multifunctional Database: This enables both InnoDB and MyISAM storage engines and divides resources evenly between the two. This is the recommended option for developers who use both storage engines on a regular basis. It’s the option I chose, since it yields the most flexibility.
  2. Transactional Database Only: This enables both InnoDB and MyISAM storage engines, but dedicates more resources to the InnoDB engine.
  3. Non-Transactional Database Only: This option completely disables InnoDB; all resources are dedicated to the MyISAM storage engine.

If you chose Multifunctional Database or Transactional Database Only, you’ll be presented a windows asking you where to put the InnoDB tablespace:


I went with the default, which puts the tablespace in the MySQL installation directory.

Concurrent Connection Settings

The next window is all about the number of concurrent connections supported:


The three choices offered are:

  1. Decision Support (DSS)/OLAP: This assumes an average of around 20 concurrent connections, with a maximum of 100 concurrent connections supports. I chose this option, as it works for most development scenarios.
  2. Online Transaction Processing: This supports up to 500 concurrent connections and is generally for production use.
  3. Manual Setting: This lets you specify a specific number of connections. I’ve seen it used mostly for testing.

Networking Options

The next window concerns itself with networking options:


Port 3306 is the default MySQL port, so that’s what I went with; I also checked the Add firewall exception for this port checkbox. I also left the Enable Strict Mode checkbox checked.

Default Character Encoding

Now it’s time to select the default character encoding:


You’re given a number of options, but I suggest you go with my choice. I chose UTF-8 because it’s the encoding of the Web.

Service Options

Here’s the next window:


I strongly recommend:

  • Checking the Install As Windows Service checkbox. When installed as a Windows service, MySQL can be started automatically at system startup and restarted in the event of a service failure.
  • Going with the default service name of MySQL unless there’s already an instance of MySQL installed, in which case you’ll want to provide a different name. Note that service names should be 255 characters or less and can have any legal character except for the forward-slash (/) or backslash (/).
  • Checking the Launch the MySQL Server automatically checkbox.
  • Checking the Include Bin Directory in Windows PATH checkbox. You’ll save yourself a lot of typing if you do this.

Security Options

And now, the Security Options window…


You’ll be asked to provide a password for the root user twice.

You can also choose to:

  • Enable root access from remote machines. I don’t really need this on my development machine, so I didn’t check this checkbox.
  • Create an anonymous account. I don’t need this either, so I didn’t check this checkbox.


That’s it for all the option setting. You’ll now be presented with this window:


If you’re satisfied with your configuration choices in the previous windows, click the Execute button. You’ll be presented with this window as your reward:


…and you’re done!

Taking it for a Quick Spin

Let’s take MySQL for a quick spin to confirm it’s working. We’ll do this using the mysql command-line client and logging in as root. There are a couple of ways to do this. One is by firing up the MySQL Command Line Client from your Windows menu (or Start Menu on XP):


A command-line window will pop up, where you’ll be prompted to enter the root password. Enter it, and you’ll be in the command-line client!


The other way is to fire up the Command Prompt and (if you specified that you wanted MySQL’s bin directory included in Windows’ PATH, which you should have), enter mysql –u root –p. The -u switch is for specifying a username, and the -p switch is for specifying that you will be providing a password for the specified username.

You’ll be prompted to enter a password. Enter the root password and you’ll be in the command-line client:


And MySQL is ready to use! You can now use the Web Platform Installer to install PHP-based apps that require MySQL.

I can’t give you a walkthrough of MySQL’s command line – that’ll have to wait for another article, or you might want to check out this article – but here’s a quick one: the show databases; command (don’t forget the semicolon at the end!) will return a list of all the databases currently in the system.

Happy MySQLing!


Wubi: Peaceful Coexistence between Vista and Ubuntu “Hardy Heron”

Switching Machines

The place where I work, b5media, is a business built on WordPress, which is based on the LAMP stack (where the “P” means “PHP”). Although my formal job title at b5 is “Technical Project Manager” and not “Developer”, the job titles aren’t rigidly defined, and I’d like to contribute my own developer skills at some point. Furthermore, I think that if you manage developers, you really should have some development skills and keep them sharp.

My preferred LAMP development platform is Mac OS X, which I feel delivers the best of both worlds: the functionality of a Unix-y operating system and the user experience — and dare I say, tasteful design — for which Apple is known and loved. In my former life at Tucows, I used my own PowerBook G4 as my primary machine, which is now my wife’s. Later, when I went to TSOT, they provided me with a 15″ MacBook Pro. When I left TSOT to join b5, the machine waiting for me was a Toshiba P200. For the first time since early 2003, my primary work machine was a PC running Vista.

It is possible to get work done in Vista, using it as a LAMP development machine feels a little awkward. While I’ve had no trouble setting up PHP under previous versions of IIS (in fact, I think my no-longer-existent docs for doing so on a Tucows site are pretty good), I have yet to successfully do it on the current version. I’ve had some success with installable LAMP stacks like Bitnami and WAMP, but somehow they still felt clunky. I also kept typing Unix commands at the DOS command line.

What I needed was a Unix I could run on my Toshiba.

A First Attempt at Ubuntu: Gutsy Gibbon

Installing Ubuntu on a desktop machine, even a “white label” one built in the dingy discount computer shop with lots of off-brand peripherals hanging on the walls, generally runs without a hitch. Getting Ubuntu to work on a laptop has typically been a completely different matter: there are generally incompatibilities galore and you have to do a lot of yak shaving in order to get a working system.

I first tried to install Ubuntu 7.10, a.k.a. “Gutsy Gibbon”, on the Toshiba. My experiences:

  • The video card worked, although it wouldn’t go to the maximum resolution (1440 by 900) without installing xserver-xorg-video-intel, which is explained here.
  • Sound didn’t work in the beginning, but once again, a little Googling found the fix. Since I use Skype voice chat in regular meetings with remote b5 developers, working audio is important. One downside: the speakers output audio even though headphones were plugged in.
  • The webcam and card reader didn’t work at all. These weren’t dealbreakers, but they were annoying.
  • My model doesn’t have it, but some versions of the Toshiba P200 come with a fingerprint reader. True to the stereotypes of the priorities of Linux people, the fingerprint reader is reported to work without any tweaking required.

I decided that I was doing more tweaking than working, so I decided to wait until Hardy Heron’s release, as it promised greater compatibility and a feature called “Wubi” that might meet my needs.

Installing Hardy Heron via Wubi

Wubi stands for Windows-based Ubuntu Installer that lets you install Ubuntu as if it were a Windows application. It doesn’t require any disk formatting or partitioning; the Ubuntu filesystem lives in a disk image within Windows’ filesystem. This setup allows Windows users to “try before they buy”, letting them take Ubuntu for a spin while still keeping their Windows applications and data.

Installation is dirt simple. You simply download the Wubi installer and double-click on it…

Wubi icon

…which takes you to this window, where you enter just enough data to start the installation process:

Wubi setup app - first screen

You need only enter these six pieces of information to install Ubuntu using Wubi:

  • The drive on which Ubuntu is to be installed
  • The amount of disk space to allot to Ubuntu (up to a maximum of 30GB)
  • Which desktop environment to use
  • Which language to use
  • A username
  • A password

Once you’ve provided this information, click Install…and that’s it. The installer does the rest:

Wubi setup app - second screen

And soon afterwards, you’re greeted by this window, which prompts you to reboot your computer:

Wubi setup app - third screen

And soon afterwards, you’re greeted with this screen:

Boot screen menu for Windows / Ubuntu

You’ll see this screen every time you boot up from now (or at least until you uninstall Wubi, which you do from within Windows; uninstalling Wubi is as simple as uninstalling any other Windows app).

Finally, you’ll see this:

Ubuntu login screen

I logged in and started checking to see if Ubuntu recognized devices on my laptop:

  • Video: check! All resolutions right up to the maximum of 1440 by 900 were supported.
  • Sound: check!
  • Card reader: check!
  • Wireless: check!
  • Webcam: once I installed Skype, check!
  • Volume dial: (It’s a hardware dial that sends volume-change messages to the system) check!
  • Screen brighten/dim buttons: check!

I checked the filesystem and found that the Windows filesystem was accessible via the host directory, meaning that I could access any files on the Windows portion of the system. I set things up so that my home directory in Ubuntu had links to some of the folders in my user directory in Windows.

All in all, it was the least complex Linux installation experience I’ve ever had. If you’re a Windows user thinking about giving Linux a try, I highly recommend taking Wubi out for a spin.