Home / Web Development / MySQL on Windows 7 64 bit – Installation with Apache and PHP
A week back I got a spanking new Sony Vaio laptop running Windows 7 (64 bit). Its been a sort of tradition with me that the first programs I install on a new computer are Apache web server with PHP and MySQL. I do this even before I setup the email client.
I have been installing and using Apache+PHP+MySQL on Windows operating system since the late 90s, so I suppose I have been around. But there was something new to learn this time. This was a 64 bit computer running Windows 7. Nothing unusual I thought… but was I wrong!
Apache and PHP are available only in 32 bit versions. MySQL, on the other hand, is offered in both 32 bit and 64 bit. For the sake of coherency and consistency, I though I’ll install only the 32 bit versions of the three programs.
So was I successful? Oh Yes! But there was one big problem and here is the full story.
Following is the list of files I installed – you can get them from the download pages of Apache.org, PHP.net and MySQL.com.
I installed Apache in C:/Apache and uncompressed PHP to C:/PHP. I then changed the httpd.conf file so that the web server knew where the PHP program was. I also made a few other minor changes.
The final step was installing MySQL and configuring an instance. This was a fairly straightforward process. I checked the MySQL command line editor and everything worked wonderfully.
It was now time to change the php.ini file so that it loaded the MySQL extension. Again, there were no problems and the phpinfo(); file showed that MySQL was being recognized. Great! I thought I was all set…
As shown by the screenshot of the phpinfo(); file, everything seems to be working without problems. But when I tried to connect to MySQL with the mysql_connect(), I got a web page not available message.
Web page not available? Was this a browser problem or an Apache problem? I was completely confounded.
With meticulous troubleshooting I came up with the following conclusions:
Conclusion: It was a MySQL 32 bit vs MySQL 64 bit issue. Though, the 32 bit software can be installed on Windows 7 and it will work without problems, PHP simply will not connect to it. You need to install the 64 bit version of MySQL on the Windows 7 64 bit operating system.
Please check out the step by step instructions with screenshots on how to install MySQL on Windows 7. You may also be interested on getting Apache web server and PHP to work on Windows 7 too!
mysql 32bit works fine by making copy of libmysql.dll to sysWOW64
src: http://stackoverflow.com/questions/569731/cant-get-php-to-work-with-mysql-on-vista-64
Yeah… brilliant!! Just about exactly what I did. Except in the past couple of years I have used WampServer with no problems. However, I began to experience no connections to a database recently I knew was working well. Since installing Windows 7 (after using Vista Ult 64bit where WampServer worked very well!) I thought there would be no issues with said program. Wrong!
So I uninstalled WampServer and then downloaded MySQL 32bit as well as the others you mention above and I too had the same issues. Even when installing MySQL 32bit I thought there may be an issue after using WampServer (it contains MySQL 32bit) but I persisted. Again no connections and commands not being recognised.
So, off to the net to obtain the 64bit MySQL and installed it and lo and behold – everything was fine again in my land of site development!
Conclusion? Not all of us are as clever as we think and program developers or MS need to get their act together!!! Either that or we need tobecome detectives!
Hi. I sure appreciate your article.
I also have a new x64 machine and am trying to get Apache2.2, PHP 5.2.12, and MySQL 5x up.
Apache is working. PHP is working (from command line), but not with Apache. When I try to install php into httpd.conf with:
LoadModule php5_module “C:/php/php5apache2_2.dll”
AddHandler application/x-httpd-php .php
PHPIniDir “C:/php”
and restart Apache, it won’t start with “The requested operation has failed!” error.
My PHP is in c:/php/ and I’ve set the entire folder to owner: “administrator” and have checked all the permissions (I think).
Any hints you might be able to help me with?
(I’m trying to use php 5.2.12 rather than 5.3.x because there is a password size bug between my hosting company’s old MySQL and my local PHP, so I need to use the older version.)
Thanks.
Please ignore my previous request. (I found my problem: had Apache 2 rather than 2.2 installed.) PHP is now serving, .. now on to MySQL.
If you’re still having issues, try 127.0.0.1 instead of localhost.
I had actually tried 127.0.0.1 too, but that didn’t work. The change to 64-bit MySQL version solved everything.
I’ve been developing SIR databases for a while and we are moving to the web. I’m running Windows 7, 64 bit, and I’ve installed Apache 2.2.15 but I can not see the simple html file that displays “It works!”. I just get the 404 error.
I’ve tried various combinations of:
Install in the “program files”
Install in the “program files (86)”
install with default options (uses port 80 same as skype so I have to edit the conf file)
install for current user (users port 8080, but then doesn’t start).
I’m an administrator on my local computer, but I just can get the http://localhost to work.
Any ideas? What am I missing?
follow up-
I download and installed the 2.2.15 “openssl” version and “It Works!” works. I don’t know why after 4 hours of hopeless helpless time loss this finally worked.
I installed apache 2.2.15 + php 5.2.13 + mySql 5.5 64bit according your articles which were pretty helpful(thanx so much.)
I have windows 7 64 bit.
I’ve created a database through sql command level. now when I run a php file to create my table I get the following error:
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:PHPextphp_mysqli.dll’ – %1 is not a valid Win32 application.rn in Unknown on line 0
[Wed May 12 17:11:49 2010] [notice] Child 1292: Child process is running
[Wed May 12 17:11:49 2010] [notice] Child 1292: Acquired the start mutex.
I done for extension as you said in your article.
I appreciate your help.
Try the solution at “PHPBuilder.
Hi Great tutorial man. I just have one question, for some reason I cannot get the mysqli and mysql parts on the phpinfo.php page. Any clue as to why this is happening? I followed your instructions very carefully and everything so far worked but those two things are the only things missing i need help any idea why man. I really appreciate it your help take care.
JR.
@Jaime R,
The MySQL service is not running on your machine.
have vaio F series 64bit and I installed all 3 using Appserv 2.6. Only thing I had to do to get the system to work was open notepad as admin and edit the hosts folder to point 127.0.0.1 to localhost. Dratted Windows 7 security.
The only thing I have yet to get working is the mail()function. It just wont send out whether locally or to my remote smtp.
Thanks. I am student and just started programming with PHP and MySQL.
Thank You! Thank You! Thank You! Can’t thank you enough!
I was at a stand still on setting up MySQL, Apache, PHP on my new Win 7 64-bit OS for a college programming course. I am proud to say I am up and running now, thanks to your very clearly written instructions!
I resolved my MySQL integration issue with PHP & Apache by setting the PATH environmental variable in Windows to include c:php (or where ever your php is installed. Hope this helps.
Is possible to re-install MySQL in Window-7? If so, then how?
@Priyaranjan
Yes, you can re-install MySQL. It’s recommended that all all files and instances are removed before you begin on a fresh installation.
How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]
Paul Buchheit is credited to have suggested Google's motto - "Don't be evil". He is also responsible for AdSense, the online advertising platform for the search engine giant. [more...]
We use cookies to give you the best possible website experience. By using WebDevelopersNotes.com, you agree to our Privacy Policy