MySQL is by far, the most popular open source database software on the web. Today we will learn how to install MySQL on the windows platform.

The Easy Method

Mysql’s site offers a pre-packaged installer for Windows systems. The install is an easy to follow GUI wizard that can be completed in three minutes. The installer offers the latest versions of:

  • MySQL Server
  • MySQL Connectors
  • MySQL Workbench and sample models
  • MySQL for Excel
  • MySQL Notfier
  • MySQL for Visual Studio
  • Sample Databases
  • Documentation

For more about this installer, check out the MySQL Installer Documentation.

You can download the installer here.

The Advanced Method

If you’re a hardcore programmer (or aspire to be) you’ll probably want to learn how to install MySQL via command line. This task is not as daunting as it sounds, especially for people who are familiar with navigating the command prompt. Non-experienced command line users need not fret, as the steps are quite simple and easy to follow along.

Step 1. Download MySQL from dev.mysql.com/downloads/.
Make sure to download the “without installer” version.

Step 2. Extract the files from the .zip you downloaded into the C: drive. Rename the folder to “mysql”.

Step 3. Now its time to make a configuration file. Create a file in the “mysql” folder called my.ini. There are many options for your configuration file but the file in it’s simplest form should look something like this:

Where the paths are replaced by the paths to your folders.

Step 4. You can start the MySQL server by navigating to the directory you installed MySQL in and type these commands into the command prompt:

Where [enter] is the action of hitting the enter key.

The top command changes your directory to the mysqldbin directory and mysqld runs the the mysqlbinmysqld.exe program (the database server).

Now that your MySQL server has started you can enter the MySQL command line tool by typing in:

You should now see the prompt change to mysql>. There will also be a welcome message if you manage to get here successfully.

Step 5. Changing the root password is a key step in the MySQL process. By default, the software comes with no password assigned to the root user, which means anyone could easily access your database and steal information.

You can change your root user’s password like so from the mysql> prompt:

Where my-new-password is your new password.
Remember: you will be asked for your password the next time you start the mysql command tool, so keep it in a safe place

Step 6. Exit the command line tool by typing “exit” and hitting enter. You should shut down the MySQL server with the following:

Now we can install MySQL as a windows service. To do so, type the following into your command prompt:

You can now go to Control Panel>Administrative Tools>Services and click on MySQL. From here you can set your startup type to Automatic to start the server on boot, or Manual, to manually start and stop the server.

To start it up from the command prompt in manual mode:

You can remove the windows service with:

Thanks for following along! Come back later for more MySQL tutorials!