Problems in installting MySQL on Windows 7 64 bit computer and making it work with Apache web server and PHP.

MySQL on Windows 7 64 bit – Installation with Apache and PHP

Posted on November 8, 2009 under Other  |  10 Comments

Sponsored Links

A week back I got a spanking new Sony Vaio laptop running Windows 7 (64 bit). Now its been a sort of tradition with me – 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. Now I have been installing and using Apache+PHP+MySQL on Windows operating system since the late 90s, so I suppose I have been around for some time.

But there was something new to learn this time. This was a 64 bit computer running Windows 7. Nothing usual I though… but was I wrong!
Both 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.

Installing MySQL 32 bit on Windows 7 64 bit computer

Following is the list of files I installed – you can find them from the download pages or Apache.org, PHP.net and MySQL.com.

The Apache web server was the first program I installed (in C:/Apache). The compressed PHP download was then unzipped to C:/PHP. I then changed the httpd.conf file so that the web server knew where the PHP program was and made other minor changes.

The final step was getting MySQL to install and have an instance configured. 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…

phpinfo() file shows that mysql and mysqli extensions have been loaded on Windows 7 64 bit system using MySQL server 32 bit

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 (in Google Chrome).
Web page not available? Was this a browser problem an Apache problem… what was going on?

With meticulous troubleshooting I came up with the following conclusions:

Conclusion: It was a MySQL 32bit vs MySQL 64 bit issue. Though, the 32 bit software could be installed on Windows 7 (and worked), PHP just couldn’t connect to it. Installing MySQL on Windows 7 64 bit computer needs the 64 bit version like mysql-essential-5.1.40-winx64.msi.

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!

Sponsored Links

10 responses to “MySQL on Windows 7 64 bit – Installation with Apache and PHP”

  • 10ha January 11th, 2010

    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

  • Brian February 5th, 2010

    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!

  • Howard February 7th, 2010

    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.

  • Howard February 7th, 2010

    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.

  • Andrew Care February 23rd, 2010

    If you’re still having issues, try 127.0.0.1 instead of localhost.

  • Manish February 24th, 2010

    I had actually tried 127.0.0.1 too, but that didn’t work. The change to 64-bit MySQL version solved everything.

  • GregNeils March 25th, 2010

    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?

  • GregNeils March 25th, 2010

    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.

  • MJ TH May 12th, 2010

    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:\\PHP\\ext\\php_mysqli.dll’ – %1 is not a valid Win32 application.\r\n 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.

  • Manish May 14th, 2010

    Try the solution at “PHPBuilder.


Comments, questions, feedback... whatever!









Subscribe to the RSS feed