How do I install MySQL on Windows 7?

How do I install MySQL on Windows 7? cover image
  1. Home
  2. How Do I
  3. How do I install MySQL on Windows 7?

This step by step guide on how to install MySQL on Windows 7 is in continuation to the Apache and PHP installations on the same operating system. Before we begin, I like you to determine the system type – whether your computer is 32 bit or 64 bit.

This is important as I had a horrendous time in troubleshooting PHP-MySQL connection problem, details of which can be found at MySQL on a 64 bit Windows 7. You can know the system type from “Control Panel” -> “System and Security” -> “System“.

Sponsored Links

Instructions to install MySQL on Windows 7

The instructions with the screenshots have been presented in a slideshow below; please refer these when in doubt. I would be guiding you through the process of downloading MySQL and setting it up on your Windows 7 computer. The installation process is not very difficult, so don’t be intimidated by the large number of slides; I just wanted to be thorough.

  • The MySQL downloads page - Community Server.
  • Download the Windows (x86, 64-bit) MSI Installer file.
  • Register for an account at the MySQL web site or simply skip the step and go straight to the downloads.
  • Choose a download mirror site.
  • Double-click on the MySQL installer (.msi) file. Choose Run when prompted.
  • MySQL welcome screen - click the Next button.
  • Accept the terms in the License Agreement.
  • Choose Custom installation.
  • Click Browse to change default folder to which MySQL installs.
  • Select the folder name.
  • Change MySQL install folder to C:\MySQL.
  • Install directory is not changed.
  • Everything's set and you are ready to install MySQL.
  • The progress bar will start moving in a short while.
  • MySQL being installed and the files being copied on your computer.
  • Click Next on promotion screens.
  • Put a checkmark here and click Finish.
  • MySQL Instance Configuration Wizard launched - click the Next button.
  • Choose the Detailed Configuration option.
  • Select Developer Machine as you would be using it for learning and development.
  • Go with the default - Multifunctional Database.
  • Select the drive - the default is just fine.
  • The Decision Support (DSS)/OLAP option is good for your developer machine - 20 connections are assumed.
  • Select Enable Strict Mode - click Next button.
  • Choose character set - Standard is fine for English and other West European languages.
  • Include MySQL bin directory in Windoes PATH.
  • Set up MySQL Server security.
  • Type in the password twice.
  • Instance Configuration Wizard is ready with all information - Click Execute button.
  • MySQL instance configured successfully - click Finish.
  • Locate the MySQL Command Live Client from the Programs menu.
  • Open the MySQL Command Line Client.
  • Enter the password (which is replaced by asterisk symbols).
  • The mysql prompt is shown and awaits commands from you.
  • Show Databases command displays the databases available on your server.
  • Right-click on php.ini and open it with Notepad
  • Uncomment the two MySQL extensions by removing the semicolons

Download MySQL installer file

  1. Be sure to choose the MySQL installer that corresponds to your system type. For me, it was the Windows (x86, 64-bit) system file, mysql-5.5.16-winx64.msi, which was 32.6 MB in size.
  2. The direct link to the page from where you can download MySQL is http://www.mysql.com/downloads/mysql/; please click on that link to load it in a browser [Slide 1]. Scroll down and locate the MSI installer file corresponding to your system type – 32 bit or 64 bit. Click the Download link/button beside it [Slide 2].
  3. You will be asked to register or sign in at your account. Registering has it’s benefits, but if you are in a hurry, simply click on the No thanks, just take me to the downloads! link [Slide 3].
  4. A list of sites from where you can download the MySQL file will be displayed [Slide 4]. Choose a ‘mirror’ which is closest to your geographical location to get the file fast. FYI, there is no problem in choosing a site located in Europe even though you are in the United States.

Setting up MySQL and making it work on your Windows 7 computer

  1. Move to the folder to which the MSI file was downloaded and double-click on it to start MySQL installation – click “Run” when prompted [Slide 5].
  2. Click “Next” button in the introductory window [Slide 6]. Accept the terms in the License Agreement by checking the box and hit “Next” [Slide 7]
  3. In the following screen, select Custom installation which will allow you to specify the folder to which MySQL will be installed [Slide 8]. FYI, choosing Typical will put MySQL deep down in the “Program Files” folder.
  4. Click the “Browse” button [Slide 9] and enter C:\MySQL in the Folder name field. Hit “OK” when done [Slides 10 and 11].
  5. The installer will change the MySQL installation folder to the one specified by you – C:\MySQL [Slide 12].
  6. You are now ready to install MySQL on Windows 7 operating system. Click “Install” [Slide 13].
  7. It would take some time for the progress bar to start moving… be patient [Slides 14 and 15].
  8. You may also get messages along the way – simply click on “Next” to proceed [Slide 16].
  9. When the process finishes, you’ll get to see the final screen. Congratulations – MySQL has been installed on your computer. You are now prompted to Configure the MySQL server; click “Finish” [Slide 17].

Configuring a MySQL instance

  1. The MySQL Instance Configuration Wizard will now launch [Slide 18]; click “Next” to proceed. Please note that you cannot use MySQL until an instance has been configured, so these steps are quite important.
  2. Select “Detailed Configuration” option [Slide 19].
  3. Choose “Developer Machine” [Slide 20].
  4. I suggest going ahead with “Multifunctional Database” unless you know what you are doing [Slide 21].
  5. In the following screen, don’t mess with the default values and click “Next” [Slide 22].
  6. The same goes for the subsequent screen; click “Next” [Slide 23].
  7. For the networking options configuration, put a check mark in front of “Enable Strict Mode” if it’s not there [Slide 24].
  8. Move ahead with the “Standard Character Set” [Slide 25].
  9. Yes, it’s recommended to install MySQL as a Windows service and have the system include the MySQL bin directory in the Windows PATH variable [Slide 26].
  10. The password for the MySQL server instance has to be typed in twice [Slides 27 and 28]. Remember to keep a note of it and don’t lose it. The password doesn’t have to be very strong because, I suppose, you would be using MySQL on your computer for learning/development and NOT production.
  11. The configuration wizard has received all the information it needs and is ready to create a MySQL server instance. Click “Execute” button [Slides 29 and 30].
  12. Ignore messages from the anti-virus program and answer in the affirmative when the Windows 7 UAC (User Account Control) asks whether you want to run MySQLInstanceConfig.exe file. Generally, the instance should be configured without any problem.
    However, if the MySQL Instance Configuration Wizard becomes unresponsive (the window shows a ‘Not Responding’ message), launch the Task Manager either from the Control Panel or use the old Ctrl-Alt-Del key combination and kill the program. Now go to C:\MySQL\bin folder and double click on MySQLInstanceCOnfig.exe file to launch the wizard once again.

Checking the MySQL installation

The easiest way to check MySQL installation and confirm that it’s working properly is to use the MySQL Command Line Client. Fire it up from “All Programs” -> “MySQL” -> “MySQL Server 5.5“[Slide 31].

Now enter the MySQL password – the characters you type will be replaced by the asterisk sign (the password is not shown for security reasons – obviously) [Slides 32 and 33].

The MySQL client displays the mysql> prompt on successful login [Slide 34]. Type show databases; (the semi-colon at the end is not a typo) and hit the enter key. This simple SQL command instructs MySQL to display the names of the installed databases and there should be four of these. Hurray! Rejoice because you have been able to correctly install MySQL on Windows 7 [Slide 35]!

Configuring PHP to work with the MySQL installation

The newly installed MySQL Server will run on it’s own without any problem and is an ideal platform to learn the SQL (Structured Query Language). However, if you want to use it with PHP, changes have to be made to the php.ini file. The appropriate ‘marriage’ of MySQL and PHP is essential for setting up program suites such as WordPress… and I’m sure many of you would be interested in that, right?

The PHP configuration file (php.ini) is located in the install directory which should be C:\PHP if you have followed my instructions on how to install PHP on Windows 7 computer. We now have to modify this file so that all the three, Apache, PHP and MySQL, work together.

Move to the PHP install folder, right-click on php.ini and open it with Notepad [Slide 36]. Using the ‘Find’ feature (Ctrl-F or Edit -> Find), locate the Dynamic Extensions section. Scrolling down, you should see a whole bunch of PHP extension lines. Remove the semicolon in front of the two mysql extensions (listed below) [Slide 37].

extension=php_mysql.dll
extension=php_mysqli.dll

Save the php.ini file and (IMPORTANT) restart the computer – this will give you time to stretch your legs. By the way, as I had mentioned in the beginning, you need a web server for PHP to work – read install Apache on Windows 7 for instructions.

Finally, if you have already been using MySQL on another computer you can quickly transfer databases and tables using mysqldump and the mysql programs.

How Do I MySQL Programming Web Development