WebDevelopersNotes logo

home-icon Home / Web Development / MySQL on Windows 7 64 bit – Installation with Apache and PHP

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

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!

Sponsored Links

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 get them from the download pages of Apache.org, PHP.net and MySQL.com.

  • apache_2.2.14-win32-x86-no_ssl.msi
  • php-5.2.11-Win32.zip
  • mysql-5.1.40-win32.msi

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…

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.
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:

  • There was nothing wrong with the configurations of Apache, PHP and MySQL.
  • PHP was able to load the mysql and mysqli extensions.
  • MySQL 32 bit worked fine from the command line editor.
  • Both mysql_connect and mysqli_connect were failing… were they not being recognized?
  • Obviously, mysql_select_db and mysqli_select_db were not working.
  • mysql_connect and mysqli_connect displayed different error (?) messages on the web page.
  • Finally a small clue through mysqli_connect() – the message had a number 8388608. This was preceded by a forward slash or a backward slash (I don’t remember). I wasn’t sure what this number was – was it some kind of error number?
  • A quick web search informed me that 8388608 was somehow linked to a memory issue – “Allowed memory size of 8388608 bytes exhausted“.
  • I deleted the old MySQL server instance and created a new one. Same result – still get the web page not available message when I try to connect to MySQL.
  • Downloaded the MySQL Windows essential file for 64 bit system – mysql-essential-5.1.40-winx64.msi.
  • Removed the 32 bit MySQL software and installed the 64 bit on Windows 7.
  • Hurray! Everything worked!

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!

Sponsored Links

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

  • 10ha on January 11th, 2010 12:46 pm

    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 on February 5th, 2010 1:36 pm

    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 on February 7th, 2010 9:29 am

    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 on February 7th, 2010 11:17 am

    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 on February 23rd, 2010 5:23 am

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

  • Manish on February 24th, 2010 7:56 pm

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

  • GregNeils on March 25th, 2010 4:47 pm

    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 on March 25th, 2010 5:00 pm

    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 on May 12th, 2010 11:51 pm

    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.

  • Manish on May 14th, 2010 10:10 am

    Try the solution at “PHPBuilder.

  • Jaime R on March 28th, 2011 8:27 am

    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.

  • Manish on March 30th, 2011 11:49 am

    @Jaime R,
    The MySQL service is not running on your machine.

  • hatton on May 3rd, 2011 9:18 am

    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.

  • cesar on June 22nd, 2011 11:30 pm

    Thanks. I am student and just started programming with PHP and MySQL.

  • JLWS on July 20th, 2011 3:20 pm

    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!

  • Jason on July 25th, 2011 12:28 pm

    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.

  • Priyaranjan on March 12th, 2013 9:08 am

    Is possible to re-install MySQL in Window-7? If so, then how?

  • Manish on March 17th, 2013 8:32 pm

    @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.

Internet Explorer jokes and funny images

Sponsored Links

Tips

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...]

Fact

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