How to install MySQL on Windows 7

Before installing MySQL make sure you have already installed Apache Server and PHP.

Download the latest Generally Available (GA) release of MySQL at Pick the Windows MSI Installer package. MySQL installer MSI 32 bit will install both 32 bit and 64 bit binaries.

Download MySQL


Update 2013

The new MySQL MSI Installer is very different with MySQL in this tutorial, so here I created a video on how to install MySQL on Windows 7. But before you watch the video, if you have already installed a local server with the old MySQL installer, here is a simple way to backup all your databases.

Open Command Prompt and enter the following line:

mysqldump -u root -p[password] -h [host] --all-databases > dump-name.sql

As an example, if my MySQL password is 12345 and I want to backup all MySQL databases and save the output sql/dump file into D drive named "mysqldump.sql" I will type something like the line below into the Command line:

mysqldump -u root -p12345 -h localhost --all-databases > d:/mysqldump.sql

With MySQL Workbench it is easy to import sql/dump file as you will see in the video.

If you don't want to install MySQL Workbench, here is how to import sql/dump from the command line:

mysql -u root -p < d:/mysqldump.sql

After you have created MySQL sql/dump file, uninstall MySQL and delete MySQL installation and data folder.

End Of Update


Once the download has completed, double click the file to begin the installation.

Install MySQL-01

Click Next to continue.

Install MySQL-02

Please read the License Agreement, if you agreed check "I accept the terms in the License Agreement" and then click Next.

Install MySQL-03

Select "Custom" for installation type.

Install MySQL-04

Click "Browse" to change the destination folder.

Install MySQL-05

In the "Look in" drop-down list, change the path to C:\Apache, then create a new folder, name it "mysql" or you could just type in "C:\Apache\mysql\" in the "Folder name" and then click OK.

Install MySQL-06

Once we've changed the destination folder, it should look like the image above. Click Next to continue.

Install MySQL-07

Click "Install" to begin installing the MySQL. Wait until the installation process is complete.

The next two windows are about MySQL Enterprise, click More to find out more otherwise click Next to continue the installation.

Install MySQL-08

Check "Launch the MySQL Instance Configuration Wizard" and then click Finish.

Install MySQL-09

Click Next,

Install MySQL-10

Check "Detailed Configuration" click Next.

Install MySQL-12

Check "Develover Machine" click Next.

Install MySQL-12

Check "Multifunctional Database" click Next.

Install MySQL-13

Click Next without any changes.

Install MySQL-14

Check "Decision Support (DSS)/OLAP" click Next

Install MySQL-15

Check "Enable TCP/IP Networking" and "Enable Strict Mode" then click Next.

Install MySQL-16

Check "Best Support For Multilingualism" click Next.

Install MySQL-17

Check "Install As Windows Service" Select Service Name to match with your MySQL version.
Check "Include Bin Directory In Windows PATH" so that we can directly access MySQL from the Command prompt. Click Next to continue.

Install MySQL-18

Select "Modify Security Settings" and then enter the root password. Don't forget the password we need it to be able to access MySQL later on. Click Next to continue.

Install MySQL-19

Click "Execute" to process the MySQL Instance Configuration.

Install MySQL-20

Click Finish to exit the MySQL Instance Configuration Wizard.


If you want to reconfigure MySQL Instance configuration, navigate to "C:\Apache\mysql\bin\" and double click "MySQLInstanceConfig.exe." You need to remove old MySQL instance configuration first before going to reconfigure a new MySQL instance configuration.

If you want to re-install MySQL, follow the steps below:
1. Uninstall MySQL from "Add Remove Programs"
2. Delete MySQL installation folder (C:\Apache\mysql) and MySQL data folder "(C:\ProgramData\MySQL)
3. Install MySQL.

Test MySQL from the Command prompt

Open up Command prompt by clicking Start menu, in the search box type in "cmd" and then press "Enter" In the command shell type in:

mysql -u root -p

Enter your MySQL password and then press Enter. If it looks like the image below, it means that the MySQL server is running properly.

Test MySQL from CMD

Type in "\q" to quit MySQL and then "exit" to exit the Command prompt.

Connecting PHP with MySQL

Open up PHP Configuration file located at "C:\Apache\php\php.ini" under the Dynamic Extensions find the extensions below:


Uncomment the extensions by removing the semicolon ";" in front of them:


Save the file and restart Apache Server.

Testing MySQL Script.

Open up Notepad, copy and paste the following codes, Enter your MySQL password and save the file into the Apache Document Root "D:\My Websites" as "mysqltest.php"

$dbPass='xxxx'; //Enter MySQL password.
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect to MySQL");
print "<h1>Connected to MySQL successfully</h1>";
mysql_select_db("$dbName") or die("Could not Select Database");
print "<h2>Database selected successfully</h2>";

Open up browser, in the address bar type in "http://localhost/mysqltest.php" and then hit Enter.

If it works it will look like the image below:

MySQL Test


In the next chapter we are going to install phpMyAdmin.


  1. I get an fatal error stating the following:

    undefined function mysql_connect() in D:\My Websites\mysqltest.php on line 6

    How do I go about it? Thanks!

    1. First, make sure you can access MySQL from the command line.

      Make sure that php_mysql.dll exist in the php extension folder.

      If the file exist, activate the extension in php.ini, and after that don't forget to restart the apache server.

      If the file not exist, download another php app.

      Now, after you've restarted the apache server try to delete php_mysql.dll, if you can delete the file it means that the php.ini or the System variable path is not configured proferly.

  2. Hello --

    I love this guide! And I hope you'll take a minute to help with a question? I followed the steps of installation, and the steps of troubleshooting as you listed on the 16th.

    * php_mysql.dll exists in C:\Apache\php\ext folder.

    * I have activated the extensions in php.ini and saved the file. (Double-checked, too, that I saved it to the right place.)

    * The system path variable includes C:\Apache\php and C:\Apache\mysql\bin names. (Should the last variable in the path end with a semi-colon?)

    * I have restarted my computer and restarted Apache.

    * The Apache installation went flawlessly, according to your instructions in previous chapters, and the PHP installation was also flawless.

    * I have set up and saved the mysqltest.php script, with my password embedded.

    When I test the script, I get a blank screen from Firefox, "website cannot display page" from IE, or HTTP internal server error 500 from Google Chrome. Chrome says "an unexpected condition was encountered." Well, duh! ;-)

    Can you help me resolve this? Thanks a million!

  3. Following up on my question posted on 22 Jan:

    When I type in the pathname as "file:///d:/my%20websites/mysqltest.php", the test succeeded. It looks like I may have done something wrong with the path variable.

    1. Should the last variable in the path end with a semi-colon?
      You don't need use semi-colon to the last variable

      I think those errors are related to the Apache or PHP.

      Or you can take a look at Apache error log - C:\Apache\logs\error.log, and see if you can find any clues to the cause of the problems.

      Recheck the Apache and PHP configuration files.

  4. Hi, Admin --

    Thanks for your help! MySQL wasn't working because I'd completely missed the step about updating with the Apache Lounge files to use PHP-VC9. I realized that tonight, filled in the blanks, and now it works great. Onward!

    1. Hi - I seem to be having the exact same problem as you. Could you please walk me through a solution.

    2. Managed to sort out the problem :)

  5. getting error:
    Fatal error: Call to undefined function mysql_connect() in E:\my websites\mysqltest.php on line 6
    and i have done all approach given above
    plzz me

  6. tutorial is awesome until this part.
    Unfortunate Oracle have developed a new Microsoft installer that is nothing like the one described in here i have installed uninstalled sql 10 times already it's driving me nuts

    1. I have updated this post and I added a video on how to install a new msi installer.

  7. AnonymousMay 14, 2013

    In your manual install you used this: C:\Apache\mysql\. However, in your video you let the install create the MySql destination folder on its own. Which is correct? Does that change the php ini file configuration?

    1. You can change the destination folder to wherever you want.
      I installed it into the default location, just to make it simpler.

      If php already installed and running, we don't need to make any change in php configuration file.

    2. AnonymousMay 15, 2013

      I went back and double-checked everything and also went ahead and installed the Apache Lounge files to use PHP-VC9 and everything finally worked.

      One snag I hit was that the Wordpress site I am backing up on the localhost is far too large to import via Wordpress or phpMyAdmin. I was able to upload it, however, by implementing instructions I found elsewhere online for using the MySQL Command Line Client.

      Thanks for your reply and for all the instructions contained on this site. My intention for some time has been to move my site to another web-hosting site, but until I found your instructions I was terrified even to start. Now that I have the site running on my localhost, I feel fairly confident I can now upload it to a new hosting service.

    3. I also ever faced that problem (big sql file), Luckly I found a script on the net called "BigDump" that helped me out of the problem.

  8. Sir,
    Thank you so much for your kindness i dont know anything about php,apache and i was confuse about mysql zip and .msi installation but i learn all these knowledge from here. God bless you. ..

    1. You're more than welcome ;)