By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Installing MySQL with Apache

How to install MySQL with apache on a windows computer.

Edited: 2015-12-03 13:07

This Tutorial will explain how to install MySQL on windows after finishing the PHP and Apache installation, start by downloading the installer from The MySQL Download Page

Installing MySQL

For this work, you should have installed PHP with the MySQL extension, if you didn't do so, simply stop Apache and run the installer again to change your installation. When you run the msi installer, simply hit next until it asks you about the type of the installation. You could chose the Typical option, but you may want to change the installation folder, in that case chose the Custom option.

Wizard Completed

When hitting next on the following dialogs, you finally get the "Wizard Completed" message, simply leave this dialog as it is, and start to configure the server.

The Configuration Wizard

After hitting next a few times more. If this is the first time you are installing MySQL, chose the Standard Configuration option and hit next. In the next dialog, you should select if you want to run MySQL as a service, you may want to include the Bin in you windows directory as well, in that case simply check the Check-Box.

Security Settings

Now you need to chose your root password, knowing this password will give access to everything in the database, and more. So i recommend not to check the box that says allow Enable root access from remote machines unless you really need this feature. Choosing a password is obviously easy, it is however recommended to include some Special Characters to make it harder to guess.

Seeing if it Works

You can test if it works by opening the command-line and typing in below line:

mysqladmin -u root -pPASSWORD version status proc

Note. There is no space between -p and the password.

Perhaps a better way to test if it works, would be to paste the below into your index.php in htdocs.

<?php
    // Your Server settings
      $MYSQL_Host  = 'localhost'; // The host to connect to, usually this is the localhost.

      $MYSQL_Uname = 'root'; // YourUserName

      $MYSQL_Pword = 'password'; // YourPassWord

      $MYSQL_Dbase = 'test'; // YourDatabase


      // The Global connection.
      $ConnectIon = mysql_connect($MYSQL_Host, $MYSQL_Uname, $MYSQL_Pword) or die(mysql_error());
      $DB_selected = mysql_select_db($MYSQL_Dbase, $ConnectIon) or die(mysql_error());
?>
<html>
 <head>
  <title>Server</title>
 </head>
 <body>
  <h1>Server</h1>
 </body>
</html>
<?php mysql_close($ConnectIon); ?>

Above would automatically output errors if any was found. Remember to set display_errors in php.ini to "On" and restart apache, i only recommend to enable displaying of errors while testing stuff.