You are on page 1of 4

Home Javascripts PHP Scripts Apache on Windows Login

How to install MySQL on Windows


Apache on Windows
Installing Apache January 4, 2011 - 1:39am — ricocheting
Installing PHP Note
Installing MySQL The older MySQL 4.0 tutorial has been completely removed as of Jan 1, 2010. The
Installing Perl official site no longer even has the 4.0 binaries available so there's no point in
Other Softw are keeping the tutorial. Please use the MySQL 5.1 tutorial below instead.
Sharing Server
FAQ & Tips MySQL 5.1
1. Download MySQL v5.1
Dow nload MySQL from http://dev.mysql.com/dow nloads/mysql/5.1.html and get the
Windows Essentials (x86) MSI Installer version. (after you click the dow nload link, if it
asks you to login scroll dow n a little and click the "No thanks, just take me to the
downloads!" link under the login form)

My file w as named: mysql-essential-5.1.54-win32.msi

NOTE about 64-bit

MySQL is the only softw are in the main list (Apache, PHP, MySQL) that has a
64-bit W indow s version. I did not test the 64-bit version of MySQL, but if
you have a 64-bit W indow s version, you should be fine if you w ant to
dow nload/install it. Otherw ise use the 32-bit version (the 32-bit version w ill
w ork on either type of machine).

2. Install MySQL v5.1


Run the MSI file and use the follow ing settings
Typical Setup
Skip Sign-Up
make sure "Configure the MySQL Server now " is checked
"Detailed Configuration"
"Developer Machine"
"Multifunctional Database"
"InnoDB Tablespace Settings" - leave everything default
"Decision Support (DSS)/OLAP"
make sure "Enable TCP/IP Netw orking" is checked and leave the port number at
3306 (at this point, if you have a firew all, it w ill usually try to access itself on the
localhost)
Leave "Enable Strict Mode" checked
"Standard Character Set"
check "Install As W indow s Service" and I w ould recommend leaving "Launch the
MySQL Server automatically" checked.
enter a root passw ord (and remember/w rite it dow n) and I w ould recommend
leaving "Enable root access from remote machines" unchecked
then hit "execute" and it'll install and set it up.

3. Getting PHP5 to work with MySQL - Official Info


Then open up your php.ini in a text editor and search for ;extension=php_mysql.dll
and remove the ; infont of that line.

Restart Apache and see if you get any errors. If it complains about "php_mysql.dll"
either your PHP extension directory isn't correct or w indow s can't find libmysql.dll
4. Testing MySQL
Testing MySQL is not exactly easy. How ever, here are the common connection strings for
PHP. I recommend dow nloading phpMyAdmin and using it to create and manage your
databases, etc.

PHP Connection test


<?php

converted by Web2PDFConvert.com
// hostname or ip of server (for local testing, localhost should work)
$dbServer='localhost';

// username and password to log onto db server


$dbUser='root';
$dbPass='';

// name of database
$dbName='test';

$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");


print "Connected successfully<br>";
mysql_select_db("$dbName") or die("Could not select database");
print "Database selected successfully<br>";

// close connection
mysql_close($link);
?>

Add new comment W AMP

Comments
Bug: My PHP 5.3 didn't include January 2, 2011 - 5:20pm — Anonymous reply
libmysql.dll
My php 5.3.3 zip file didn't include a libmysql.dll file that you refer to in your instructions. Huh?

Answer: MySQL and PHP prior to January 4, 2011 - 12:37am — ricocheting reply
5.3
Apparently as of PHP v5.3.0 "libmysql.dll isn't needed anymore as mysqlnd was introduced as
client library."

How ever, if you still refer to their official installation instructions they still talk about
libmysql.dll as does the text files including in the zip. That's aw esome ...

I'm going to quote my original instructions here for anyone using PHP older than 5.3.0:

Unfortunately PHP5 removed built-in support for MySQL. To get it to work, the
easiest way is to copy the mysql library file by hand. Open the folder you
unzipped your PHP to. Copy the libmysql.dll file (should be located like
C:\php\libmysql.dll ) into your Window's System folder (usually
C:\Windows\System32\ although might be C:\WinNT\System\ or something).

People using new er versions of MySQL shouldn't have to w orry about it anymore (I did a
clean install of everything and it does appear libmysql.dll is not needed anymore).

I updated the tutorial to reflect all this, but it w ould be nice if someone can confirm all this
that it w orked for them w ithout messing w ith libmysql.dll

Bug: localhost not wanting to November 23, 2010 - 11:51pm — Anonymous reply
connect
If you are not able to connect try replacing "localhost" w ith "127.0.0.1" =)

Re: localhost not wanting to November 26, 2010 - 9:35pm — Anonymous reply
connect
After some digging, I think the problem has to do w ith W indow s 7 hosts file
C:\Windows\System32\drivers\etc\hosts and it not correctly mapping localhost to
127.0.0.1 by default.
Anyw ay, I used "127.0.0.1", and it w orked. Thank you very much! I w ould have never

converted by Web2PDFConvert.com
figured that out. :)

Fatal error: Call to undefined function July 13, 2010 - 11:53pm — Anonymous reply
mysql_connect()
I get this error - i did restart apache a few times to make sure
Fatal error: Call to undefined function mysql_connect() in
C:\webserver\Apache\htdocs\mysqltest.php on line 12

(64-bit Windows 7) Call to undefined July 22, 2010 - 5:09am — Psychosis reply
function mysql_connect()
If you are running a 64-bit version of W indow s 7 (such as I am), I noticed that I get the
same error if I put libmysql.dll in C:\W indow s\System32 as suggested. If libmysql.dll is
placed in C:\W indow s instead, PHP w ill see libmysql.

Finally a Solution! October 3, 2010 - 11:26am — Anonymous reply


I've been all over the internet and this w as really driving me crazy. I finally stumbled on
your comment and like magic everything w orked!

This solution worked for me August 24, 2010 - 4:02pm — mhasnain reply
This solution w orked for me perfectly. It took me several attempts, but it w orked.
W henever you make a change, reboot your computer.

Error while installing MySQL July 9, 2010 - 7:53am — Anonymous reply


I got this error.
Could not connect to Service Control Manager. Error: 0

Please help,
madan712

Answer - Service Control Manager July 9, 2010 - 12:53pm — ricocheting reply


Your "Could not connect to Service Control Manager. Error: 0" is MySQL complaining it does
not have access to W indow 's service manager.

1) You need to make sure you are installing MySQL as Administrator. You can't do it from a
limited account.

2) Your "User Access Control" in Vista (W indow s 7 also has a similar setting) might be set to
high. The settings for that should be somew here under Control Panel > User Accounts (I'm
currently not at a machine w here I can check the exact location or w ording).

Could not start the service MySQL July 5, 2010 - 3:14am — Anonymous reply
service error:0
Hii..I tried to install MySQL as you suggested but w hen i try to execute at the last screen....its
show ing an error message like
Could not start the service.MySQL error:0.

Please Help me!!!Im banging my head against my keyboard to solve this problem from w eeks..

Could not start the service MySQL July 22, 2010 - 4:55am — Psychosis reply
service error:0
May I also suggest that you right-click on the MySQL installer, scroll dow n to properties and
look at the bottom of that w indow . Some versions of W indow s w ill block files that have been
dow nloaded from the net, until you explicitly go into the properties w indow for that file and
click the unblock button. If your installer w as blocked, I w ould suggest removing your MySQL
server instance, then uninstalling MySQL all together, physically go into your program files
folder and delete the MySQL folder that w ill still exist after you uninstall. Then go through
and reinstall MySQL as suggested.

converted by Web2PDFConvert.com
Answer - Further MySQL Debugging July 5, 2010 - 1:07pm — ricocheting reply
I've had several people tell me if they manually change the service name to something other
than default (like "dbmysql5") w hen installing the service it then w orks for them.

There should also be an error file in the mysql data directory named like
<my_hostname>.err that you can open in a text editor. It might provide you w ith more
details.

Also you can try to start mysql from command prompt like:
C:\Program Files\MySQL\MySQL Server 5.0\bin> mysqld-nt.exe --console
w hich should also give you more details.

Scripts & design created 2000-2010 ricocheting.com :: Use Policy

converted by Web2PDFConvert.com

You might also like