Submitted by ricocheting on
Note
The older MySQL 4.0 tutorial has been completely removed as of Jan 1, 2010. The official site no longer even has the 4.0 binaries available so there's no point in keeping the tutorial. Please use the MySQL 5.1 tutorial below instead.
MySQL 5.1
Download MySQL v5.1
Download MySQL from http://dev.mysql.com/downloads/mysql/5.1.html and get the Windows Essentials (x86) MSI Installer version. (after you click the download link, if it asks you to login scroll down a little and click the "No thanks, just take me to the downloads!" link under the login form)
My file was named: mysql-essential-5.1.54-win32.msiNOTE about 64-bit MySQL is the only software in the main list (Apache, PHP, MySQL) that has a 64-bit Windows version. I did not test the 64-bit version of MySQL, but if you have a 64-bit Windows version, you should be fine if you want to download/install it. Otherwise use the 32-bit version (the 32-bit version will work on either type of machine). Install MySQL v5.1
Run the MSI file and use the following 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 Networking" is checked and leave the port number at 3306
(at this point, if you have a firewall, it will usually try to access itself on the localhost)
Leave "Enable Strict Mode" checked - "Standard Character Set"
- check "Install As Windows Service" and I would recommend leaving "Launch the MySQL Server automatically" checked.
- enter a root password (and remember/write it down) and I would recommend leaving "Enable root access from remote machines" unchecked
- then hit "execute" and it'll install and set it up.
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 windows can't find libmysql.dllTesting MySQL
Testing MySQL is not exactly easy. However, here are the common connection strings for PHP. I recommend downloading phpMyAdmin and using it to create and manage your databases, etc.
PHP Connection test<?php // 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: ". mysql_error()); print "Connected successfully<br>"; mysql_select_db("$dbName") or die("Could not select database"); print "Database selected successfully<br>"; // close connection mysql_close($link); ?>
Comments
July 5, 2010 - 3:14am — Anonymous
Could not start the service MySQL service error:0
Hii..I tried to install MySQL as you suggested but when i try to execute at the last screen....its showing 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 weeks..
July 5, 2010 - 1:07pm — ricocheting
Answer - Further MySQL Debugging
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 with more details.
Also you can try to start mysql from command prompt like:
December 24, 2014 - 2:04pm — Alejandro Olryd
Using --console
4 years later this thread saved me! To further add a bit of light to these situations:
Using --console will display a heap of information. Read through it carefully because it's very easy to miss the important stuff about what is actually going wrong.
In my case, --console was displaying a few lines of information that said that MySQL was not being able to write to a specific folder; even though I was admin! My solution was to create a new folder (named it My_Programs) and changed the security setting so that I had complete control over it (one would think that being admin and creator of the folder would give you full control... but this is Windows we are talking about....). With that done I re-installed MySQL but forced it to install on my newly created folder (even the ProgramData).
This solved my issue.
So again, if you use --console read through it thoroughly.
Thanks to Ricocheting for this!!!!!
July 22, 2010 - 4:55am — Psychosis
Could not start the service MySQL service error:0
May I also suggest that you right-click on the MySQL installer, scroll down to properties and look at the bottom of that window. Some versions of Windows will block files that have been downloaded from the net, until you explicitly go into the properties window for that file and click the unblock button. If your installer was blocked, I would suggest removing your MySQL server instance, then uninstalling MySQL all together, physically go into your program files folder and delete the MySQL folder that will still exist after you uninstall. Then go through and reinstall MySQL as suggested.
July 9, 2010 - 7:53am — Anonymous
Error while installing MySQL
I got this error.
Could not connect to Service Control Manager. Error: 0
Please help,
madan712
July 9, 2010 - 12:53pm — ricocheting
Answer - Service Control Manager
Your "Could not connect to Service Control Manager. Error: 0" is MySQL complaining it does not have access to Window'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 (Windows 7 also has a similar setting) might be set to high. The settings for that should be somewhere under Control Panel > User Accounts (I'm currently not at a machine where I can check the exact location or wording).
July 13, 2010 - 11:53pm — Anonymous
Fatal error: Call to undefined function 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
July 22, 2010 - 5:09am — Psychosis
(64-bit Windows 7) Call to undefined function mysql_connect()
If you are running a 64-bit version of Windows 7 (such as I am), I noticed that I get the same error if I put libmysql.dll in C:\Windows\System32 as suggested. If libmysql.dll is placed in C:\Windows instead, PHP will see libmysql.
August 24, 2010 - 4:02pm — mhasnain
This solution worked for me
This solution worked for me perfectly. It took me several attempts, but it worked. Whenever you make a change, reboot your computer.
October 3, 2010 - 11:26am — Anonymous
Finally a Solution!
I've been all over the internet and this was really driving me crazy. I finally stumbled on your comment and like magic everything worked!
July 9, 2011 - 1:34pm — Anonymous
No Result!!!
I have tried your solution and I am getting no result. I have made sure extension=php_mysql.dll is uncommented in php.ini. I have put libmysql.dll in System32, then Windows, then restarted my computer...still no result.
Please, I would appreciate any help.
November 23, 2010 - 10:51pm — Anonymous
Bug: localhost not wanting to connect
If you are not able to connect try replacing "localhost" with "127.0.0.1" =)
November 26, 2010 - 8:35pm — Anonymous
Re: localhost not wanting to connect
Anyway, I used "127.0.0.1", and it worked. Thank you very much! I would have never figured that out. :)
January 2, 2011 - 4:20pm — Anonymous
Bug: My PHP 5.3 didn't include libmysql.dll
My php 5.3.3 zip file didn't include a libmysql.dll file that you refer to in your instructions. Huh?
January 3, 2011 - 11:37pm — ricocheting
Answer: MySQL and PHP prior to 5.3
Apparently as of PHP v5.3.0 "libmysql.dll isn't needed anymore as mysqlnd was introduced as client library."
However, 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 awesome ...
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 newer versions of MySQL shouldn't have to worry 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 would be nice if someone can confirm all this that it worked for them without messing with libmysql.dll
February 15, 2011 - 4:27pm — Anonymous
Error: Access denied for user
i get this error while installing mysql server..
the security setting could not be applied to the database because connection has failed with the following error:
Error No.1045
Access denied for user 'root'@'localhost'(using password:YES)
please suggest something as soon as possible...
February 15, 2011 - 5:21pm — ricocheting
Answer
[edit] found several people claiming this worked, but I have no way to test it myself. but from reading the posts it seems to be a problem that occurs when reinstalling/upgrade mysql, not with with a clean install:
http://forums.mysql.com/read.php?11,39440,368585#msg-368585
June 14, 2011 - 3:52pm — Anonymous
configuration error starting mysql service
Am trying to install v. 5.5 for Windows. I get the following error during the configuration step:
mysql-server-5.5-win32-gpl:99 - Unable to configure service.
I did a search on the internet and found one other person had the same issue, but no one has posted a solution. Any help would be greatly appreciated.
For reference, here's the entire configuration step details:
mysql-server-5.5-win32-gpl:9 - Looking for valid template
mysql-server-5.5-win32-gpl:18 - Found valid template.
mysql-server-5.5-win32-gpl:27 - Attempting to process template.
mysql-server-5.5-win32-gpl:36 - Processed template.
mysql-server-5.5-win32-gpl:45 - Attempting to configure service.
mysql-server-5.5-win32-gpl:54 - Configured service.
mysql-server-5.5-win32-gpl:63 - Attempting to start service.
mysql-server-5.5-win32-gpl:99 - Unable to configure service.
mysql-server-5.5-win32-gpl:100 - Product configuration controller finished configuration.
June 15, 2011 - 8:27pm — ricocheting
Answer
I don't have any answer either, but maybe someone else will. In a general sense, I have seen errors related to config/starting of the mysql service because there was an already existing mysql service (left from a unsuccessful uninstall). But nothing from your message really suggests that could be the problem.
June 16, 2011 - 1:38pm — Anonymous
problem fixed?
I think I may have solved the problem. On http://dev.mysql.com/doc/refman/5.5/en/windows-server-first-start.html I found some post-installation procedures to start the server. I then created a new connection and a new server instance following the procedures on http://wb.mysql.com/?p=406. Both succeeded. I know next to nothing about db management or db programming, but hope that I can now begin working through some tutorials. Thanks for providing a forum for sharing issues.
September 2, 2011 - 12:54pm — Anonymous
Solution: Cannot start service
On windows 7 there is a hidden folder C:\ProgramData\MySQL\ that will continue to store information even after you uninstall MySQL. If you are later try to reinstall and get a "Cannot start service" error, deleting that folder and then reinstalling may allow the service to start properly.
[SITE ADMIN WARNING: not personally tested]
October 8, 2011 - 2:53pm — Anonymous
This is the SOLUTION I found for Win 7
Big thank you to "Anonymous" above. I spent a whole day fighting and trying to reinstall MySQL. If you have installed MySQL 64-bit on Windows7 and want to install MySQL 32-bit, I recommend doing exactly this:
Some of my steps above could be unnecessary, but I describe exactly what I did and this works!
[SITE ADMIN WARNING: not personally tested]
September 13, 2011 - 2:00pm — sanjida
Getting an Error when retstarting Apache 2.2
Hey! I followed all the steps mentioned in this article however, when restarting apache, I am coming across this error. Can anyone please explain the reason behind this. Thanks in advance!
PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified modul could not be found.
September 13, 2011 - 2:18pm — sanjida
Solution
Ok never mind! I figured the solution to this problem :)
All you have to do is copy the "libmysql.dll" file from your php directory and then store it in C:/windows/system32
December 7, 2011 - 7:12pm — peterbug
MySQL Installation
I installed php 5.3.8 with apache 2.2.21 and MySQL 5.1.60 on my VISTA machine and tested with no problems but when I did the same installation on my Win 7 machine and ran the recommended test program i get
Fatal error: Call to unudentified function mysql_connect() in c:/........ (where the php program is) on line 12 (which is the calling line of code).
The phpinfo() on the VISTA machine shows both mysql and mysqlnd but the Win 7 machine shows only mysqlnd. I have read most everything on here and tried several different things with no good results.
December 8, 2011 - 11:41am — ricocheting
Answer
That usually means PHP is not loading the MySQL library. Doublecheck you uncommented the correct line from step #3 on this page and that your extension_dir from Step #4 on How to install PHP on Windows is set to the correct folder.
December 25, 2011 - 7:26am — Anonymous
mysql_connect()
Oh finally.
I've copied the libmysql.dll in the php file to C:\WINDOWS\system32 and it worked! Anyway thanks, I found the solution later in the page.
April 13, 2014 - 4:32pm — arpan jain
error 1045
i am havin problem in installing mysql . in last step where i have to tick 4 option . but last option is giving problem. unable to tick that option. please help me out
April 13, 2014 - 5:57pm — ricocheting
Answer
Error 1045 usually has to do with an incorrect password. I can't be much more help than that. If you need to reset the MySQL password on windows, I do have that instructions for that here.
July 13, 2015 - 11:33am — Harsha
installation error
Hi im harsha. I tried to install my sql 5.1 in windows 7 ultimate(64 bit) but an error occurred while applying security settings. So can you pls help md regarding this error.
Thank you