# VBForums UtilityBank > UtilityBank - Tutorials >  Installing MySQL Server 5.5 on Windows 7

## penagate

*Note:* If you're planning to use MySQL with PHP, follow the tutorial Installing PHP 5.3 and Apache HTTP Server on Windows 7 first, if you haven't done so already.

At the time of writing, the latest stable version is 5.5.13.


*Installing MySQL*

Get it from here:
http://dev.mysql.com/downloads/mysql/5.5.html

(Don't be fooled!  You don't need to create an account.  Follow the link "No thanks! Just take me to the downloads.")

Grab the installer  it's much smaller than the zip archive.
You can use either the 32 or 64-bit version.  Both will work with a 32-bit PHP.
Proceed through the wizard, selecting a 'Typical' installation.
You will see a 'MySQL Enterprise' popup at some point.  Dismiss it.
Once the wizard has finished, the MySQL Server Instance Configuration Wizard starts.
Select 'Detailed Configuration'.
Select 'Developer Machine'.
Select 'Multifunctional database'.
Select a drive.
Select 'Manual setting', then enter a small number of concurrent connections.


The default server port is 3306.  If you change this, you'll need to specify the port in any applications that connect to the server.
Select 'Best Support for Multilingualism'.  This will set the default character set to UTF-8.
Select "Include Bin Directory in Windows PATH".


Enter a password, then finish the wizard.
The settings will be written to a file (my.ini).
If the wizard freezes for more than about 20 seconds at this point, close it and run it again... It's in bin under the directory where you installed MySQL.
Test the installation by running the MySQL command-line client.


Create a test database.  We'll use this in the next section.



*Configuring the MySQL Client*

If this is a development machine, you might want to set up your client to log in as 'root' by default.  To do this, set up a file called my.cnf and place it in your C:\ directory.



```
[client]
user=root
password=PASSWORD
```

(On Unix platforms, the MySQL client looks in your home directory for this file. Frustratingly, the Windows client does not do this.)


*Connecting to MySQL from PHP*

Open the php.ini configuration file in a text editor.

Find the line ; extension_dir = "ext" and change it to:


```
extension_dir = "c:\php\ext\"
```

(If you installed PHP into a different directory, use that path instead.)
Find the line ;extension=php_pdo_mysql.dll and uncomment it by removing the semicolon.
Restart the Apache server.
Copy the following listing into a new file under your htdocs directory.



```
<?php
	header('Content-type:text/plain');
	$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'PASSWORD');
	$st = $dbh->prepare('select bar from foo');
	$st->execute();
	var_dump($st->fetch(PDO::FETCH_ASSOC));
?>
```

Navigate to that file using your web browser.  You should see something like this:


Great success!

----------


## Nightwalker83

Great tutorial penagate.

----------


## pipewrench

do you realize how long I have been trying to get my php script to accept  my sql5.5 and my php 5 installation. Install, delete,reboot install ahhhhhgg!!!

thought I had it once at 4am but it was just a coffee buzz. changed the script on dreamweaver and changed the path on the environment etc etc.

I'm a newbie and all but it should not be that hard to point to the database with php .

just when I was giving up i googled for the 60th time and what did I see..your post and being desperate I closed my eyes and typed what seemed like the 1000th change. what was it i saw............

IT works!!!!!!!

you are a bloody miracle...thank you from the bottom of my heart!!!now I can go to sleeep !!! :big yellow:

----------


## penagate

Sleep well!  Glad to have helped.

----------


## pipewrench

to add to this :--->my code is ;
<?php

$link=mysql_connect('localhost:3306;dbname=test', 'root', 'password');

if (!$link)
{
	$output="unable to connect to the database server.";
	include 'output.html.php';
	exit();
}

?>

remember the port# and all is well. ....thanks again..this does work perfectly

----------


## asoc1210

On the last step I get

<br />
<b>Fatal error</b>:  Class 'PDO' not found in <b>C:\Apache2\htdocs\test2.php</b> on line <b>3</b><br />

Everything else has worked great, though. So close, please help.

----------


## penagate

Silly question perhaps, but did you do steps 1 and 2 in the last section?

If so, what versions of the software are you using?
Did you also install an up-to-date PHP?

Are you using a 64-bit Windows, and if so, did you install 64-bit versions of any of the packages?
I have had trouble getting PDO to work on a 64-bit system in the past because of incompatible libraries.  I don't remember the exact solution, but if you install everything according to my two tutorials (Apache/PHP and this one), it ought to work.  In particular I use VC9 builds of Apache and PHP.

----------


## asoc1210

I used the VC6 builds and the x86 MySQL 5.5.16.

I tried the exact ones you specified and it worked like a charm. Should have done that in the first place.

Thanks very much!

----------


## penagate

Great to hear.

----------


## Nightwalker83

:LOL:  I have the same notes on my hard drive although, my lecturer included more pictures in his version.

----------


## penagate

Bah.  There are too many pictures in this one.

----------


## Nightwalker83

I think you also should include a section on how to solve specific errors for example error nr. 1045 which, I am currently trying to solve.

----------


## penagate

OK.  The only problem with that is that I have never run into error 1045.
Could it be the Windows firewall?

----------


## Nightwalker83

> OK.  The only problem with that is that I have never run into error 1045.
> Could it be the Windows firewall?


I think it might have something to do with admin rights on the operating system.

----------


## salmanmanekia

Hi,
The last step doesnt works for me,it does not display anything on the webpage ,all other step in both the tutorial went fine and resulted as anticipated..
Wondering .. ?? .. :S

----------


## penagate

How did you install PHP?
Do you have the display_errors option on?

----------


## ahmedkhairy

thanks alot.. keep it up

----------


## sagar.dafle

> Silly question perhaps, but did you do steps 1 and 2 in the last section?
> 
> If so, what versions of the software are you using?
> Did you also install an up-to-date PHP?
> 
> Are you using a 64-bit Windows, and if so, did you install 64-bit versions of any of the packages?
> I have had trouble getting PDO to work on a 64-bit system in the past because of incompatible libraries.  I don't remember the exact solution, but if you install everything according to my two tutorials (Apache/PHP and this one), it ought to work.  In particular I use VC9 builds of Apache and PHP.



Hi Penagate,
I am using win-7 32 bit system.
Installed PHP 5.3 (5.3.27) VC9 x86 Non Thread Safe version from php official site
Installed httpd-2.2.25-win32-ssl_0.9.8-VC9 (Apache server) ..
Did the setting as shown in the http://http://www.vbforums.com/showt...r-on-Windows-7 and successfully i was able to RAN php scripts via apache server ..

Today i wanted to configure MYSQL db to PHP and apache so i have downloaded and installed mysql-5.5.13-win32 as per the instructions above .
But I am getting following error  :Frown:  

*<br />
<b>Fatal error</b>:  Uncaught exception 'PDOException' with message 'could not find driver' in C:\apache2\htdocs\mysql-php.php:3
Stack trace:
#0 C:\apache2\htdocs\mysql-php.php(3): PDO-&gt;__construct('mysql:host=loca...', 'root', 'root')
#1 {main}
  thrown in <b>C:\apache2\htdocs\mysql-php.php</b> on line <b>3</b><br />* 

P.S : my db name is :test_schema ; table name : sample password and username : root 

I have create my.cnf file as you suggested in C: drive with following contents :
[client]
user=root
password=root

PLEASE HELP ME WHERE AM I GOING WRONG !!!

----------


## penagate

That message means that the pdo_mysql library is missing from your PHP installation.

Check for this line in php.ini:


```
;extension=php_pdo_mysql.dll
```

Make sure it's uncommented (remove the leading semicolon).


Also, I'm not sure you have the right versions of all the software.  I wrote these two tutorials a couple of years ago and they're a bit out of date now.

I would recommend the following for you:

Apache httpd VC11 x86
http://www.apachelounge.com/download...win32-VC11.zip

PHP 5.5 VC11 x86 thread-safe
http://windows.php.net/downloads/rel...2-VC11-x86.zip

Install those following the same procedure and see how you go.


Also also... the my.cnf file is only read by the command-line MySQL client — you will still need to supply credentials when connecting from PHP.

----------


## sagar.dafle

Thanks Penagate !  :Smilie:  
You rock !!
It worked by just removing the comment ( :Wink:  from *;extension_dir = "c:\php\ext\"* to *extension_dir = "c:\php\ext\"*  :Smilie:  

It just clicked in my mind that i should uncomment this part too :P

----------


## jkumar29

After complete installation ofApache2.4 and PHP5.5. When I run wordpress website I have got error message of "Your PHP installation appears to be missing the MySQL extension which is required by WordPress.". Please help - Thanks

----------


## jkumar29

> After complete installation ofApache2.4 and PHP5.5. When I run wordpress website I have got error message of "Your PHP installation appears to be missing the MySQL extension which is required by WordPress.". Please help - Thanks


I have found the solution.
1. Go PHP folder and open php.ini file
2. find ;extension=php_mysql.dll and ;extension=php_mysqli.dll
3. Remove semicolon 
Example:
extension=php_mysql.dll
extension=php_mysqli.dll

----------

