In this walkthrough we are going to look at installing and configuring MySQL to work with PHP on an IIS 6.0 web server. If you have not already installed PHP you can do so by following the steps in this article.
Installing MySQL on the Server
Start by downloading MySQL. You can get the latest stable release version here :
http://dev.mysql.com/downloads/mysql/5.0.html
In this tutorial I am going to be using the Windows Essentials (x86) version which has all the core functionality you need to run a MySQL database server. Launch the mysql-essential-5.0.26-win32.msi installer file to start the MySQL Setup Wizard.
Click Next and then choose a custom installation as this will allow us to specify an installation directory of our own choosing. In this example I will be using installing MySQL into the ‘C:\MySQL’ folder.
On the Custom setup dialog box click Change to specify the preferred installation directory.
Select the directory you want to use and then click OK to go back to the Custom setup dialog box.
Click next. MySQL is now ready to be installed. Click Install to begin the installation.
At the MySQL.com Sign Up screen click Skip Sign-Up and then click Next.
On the next dialog box ensure that ‘Configure the MySQL Server now’ tick box is checked and click Finish.
The Server Instance Configuration Wizard is now launched. Click Next to begin configuring your MySQL server.
Choose Detailed Configuration and click Next.
In this example I am installing MySQL on the same machine as my IIS web server so I opt for the Server Machine option. Choose a server type which is appropriate for your requirements and click Next.
Choose the type of database which best suits your needs and click Next.
Leave the default setting of the MySQL installation path for the InnoDB Tablespace settings (unless you wish to change it) and click Next.
Select the appropriate number of concurrent connections you want to allow and click Next.
Leave the default networking options settings (unless you have reason to change them) and click Next.
Choose the appropriate character set for your requirements and click Next.
On the Windows options dialog box ensure that both ‘Install As Windows Service’ and ‘Include Bin Directory in Windows Path’ tick boxes are selected and click Next.
In the security options dialog box ensure that ‘Modify Security Settings’ is ticked and type in your new root password. Decide whether or not you wish to allow root access from remote machines or create an anonymous account and click Next.
If you are happy with the choices you have made click Execute to begin configuring your server.
Once the Configuration Wizard has finished click Finish to begin using your new MySQL server.
Now that we have got MySQL installed we need to create a test user account which we will use later in this walkthrough to test connectivity to MySQL from a PHP script. Start by opening the MySQL Command Line Client. When prompted enter your root password and hit enter.
Type the following SQL command and hit enter :
CREATE USER ‘phptest’@'localhost’ IDENTIFIED BY ‘phptest’;
Then type this SQL command and hit enter :
FLUSH PRIVILEGES;
Now type this SQL command and hit enter :
SELECT Host, User, Password FROM mysql.user;
As you can see we have now created a new MySQL user account called ‘phptest’ with a password of ‘phptest’. This user account can log in to MySQL but has not been granted any permissions on any of the existing schema or databases.
Configure PHP for MySQL Connectivity
Now that we have got both PHP and MySQL installed on the server we can move on to the job of getting PHP connected to MySQL.
The first thing we need to do is enable the MySQL extensions for PHP to use. To do this locate the Dynamic Extensions section of your ‘php.ini’ file and either uncomment or add the following lines to the top of the existing list of extensions :
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
You may find that the line referencing php_mysqli.dll is not in your php.ini file - if not you will need to add it to the list. Once you have done this save the changes in the ‘php.ini’file and then either recycle your PHP web site’s application pool or perform an IISReset for the changes to take effect. If you now browse the http://localhost/index.php file we created in the first article you should see that support for MySQL is now enabled.
We are now ready to go ahead with a simple test script to ensure everything is setup correctly. Start by creating a new text file in Notepad in the root of your PHP test web site and then type in the code shown here :
Alternatively, you can download the file from here :
Save the file as dbtest.php and then browse to http://localhost/dbtest.php on your server. You should see the error message shown below.
This indicates two things. First, that we have successfully connected to MySQL from our test PHP script and second, that the user account we specified in our connection string does not have sufficient privileges to access the ‘mysql’ system database.
So you should now have a working installation of PHP and MySQL running on your IIS 6.0 server. In the final article in this series I will demonstrate how to install WordPress on an IIS 6.0 web server.
- Board index
- Search
-
- It is currently Sat Apr 27, 2024 12:09 pm
- All times are UTC+05:30
How To Install MySQL to work with PHP on IIS 6.0
Windows OS Specific Topics
Jump to
- Programmable Electronics
- ↳ Arduino
- ↳ Raspberry Pi
- ↳ Microcontrollers
- ↳ FPGA
- ↳ Digital Signal Processors
- ↳ Other
- Programming
- ↳ Web programming
- ↳ PHP & MySQL
- ↳ ASP & ASP.Net
- ↳ .Net & Other Programming
- ↳ .NET Programming
- ↳ Visual Basic Programming
- ↳ Java Programming
- ↳ C/C++ Programming
- Engineering
- ↳ Electronics & Electrical Engineering
- ↳ Embedded Systems
- ↳ Computer Science
- ↳ Software Engineering
- ↳ Data Structures & Algorithms
- ↳ Programming Languages & Compiler Theory
- ↳ Operating Systems
- ↳ Cryptography
- ↳ Computer Networks
- ↳ SQL & Database
- ↳ Computer Architecture
- ↳ Graphics & Vision
- ↳ Artificial Intelligence
- ↳ Neural Networks
- ↳ Multimedia
- ↳ Mathematics
- ↳ Other
- ↳ Control Systems & Robotics
- ↳ Mechanical
- ↳ Thermodynamics
- ↳ Fluid Dynamics
- ↳ Aerodynamics
- ↳ Manufacturing
- ↳ Energy
- ↳ Dynamics
- ↳ Statics
- ↳ Automobile
- ↳ Other
- ↳ Other
- Operating Systems
- ↳ Windows
- ↳ Linux
- ↳ Mac OS
- ↳ Android
- ????? ????
- ↳ ???????? ?????
- ↳ ??????? ???? ?????
- ↳ ????? ?????? ???? (Buy Guide)
- ↳ ??????? ???? ??????? (Where to buy)
- ↳ ????????? ???????? (Recommend - Complain - Review)
- General
- ↳ News & Announcements
- ↳ General Discussions
- ↳ Viruses, Trojans, Spyware and Adware
- ↳ Computer & Network Security
- ↳ Web Related
- Members Zone
- ↳ Project Assistance
- ↳ Advertising
- ↳ Jobs & Investment Opportunities
- ↳ Introductions
- ↳ Presents & Donations
- ↳ Entertainment
- ↳ Music & Albums
- ↳ Movies
- ↳ Games