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.
Download MySQL v5.1Download 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.msi
NOTE 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.1Run 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 InfoThen 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.dll
Testing MySQLTesting 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); ?>