Download the latest Generally Available (GA) release of MySQL at http://dev.mysql.com/downloads. Pick the Windows MSI Installer package. MySQL installer MSI 32 bit will install both 32 bit and 64 bit binaries.
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.
Click Next to continue.
Please read the License Agreement, if you agreed check "I accept the terms in the License Agreement" and then click Next.
Select "Custom" for installation type.
Click "Browse" to change the destination folder.
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.
Once we've changed the destination folder, it should look like the image above. Click Next to continue.
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.
Check "Launch the MySQL Instance Configuration Wizard" and then click Finish.
Check "Detailed Configuration" click Next.
Check "Develover Machine" click Next.
Check "Multifunctional Database" click Next.
Click Next without any changes.
Check "Decision Support (DSS)/OLAP" click Next
Check "Enable TCP/IP Networking" and "Enable Strict Mode" then click Next.
Check "Best Support For Multilingualism" click Next.
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.
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.
Click "Execute" to process the MySQL Instance Configuration.
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.
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"
<?php $dbServer='localhost'; $dbUser='root'; $dbPass='xxxx'; //Enter MySQL password. $dbName='test'; $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>"; mysql_close($link); ?>
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:
In the next chapter we are going to install phpMyAdmin.