Installing MySQL
Installing MySQL is fairly straightforward for both Windows and Linux. You can get the latest versions of MySQL from http://www .mysql.com/download.html. From there, click on the appropriate download link for your operating system.
If you are using Windows 95/98 or NT, download the latest shareware version. You'll need to fill out a short registration questionnaire before you can download the setup program.
Once you have downloaded the shareware version, extract the zip file and execute the setup.exe program. The setup program should install the MySQL files in C:\mysql.
Then all you need to do is start the MySQL server daemon by executing the command C:\mysql\mysqld install. Subsequently, you can start the MySQL server daemon by issuing the command C:\mysql\mysqld. Remember that the MySQL server daemon must be running if you want to connect to your databases using PHP.
If you are using a flavor of Linux that supports Red Hat's RPM format, I strongly recommend downloading one of the RPM binary versions of the latest stable release of MySQL. The RPM versions install all the necessary startup scripts, and generally take a lot of the headaches out of compiling your own binary version from the source code.
To install the RPM version of MySQL just issue the command rpm ivh <MYSQL-RPM>.rpm, where <MYSQL-RPM> is the name of the MySQL RPM package that you downloaded. This package automatically installs the startup scripts and configures the default databases.
As always, be sure to read the installation documentation that is available on the MySQL Web site for more detailed information.
Setting up PHP to Work with MySQL
After you have installed MySQL, you'll need to make a few minor adjustments to your PHP installation before the two programs will play nice with each other. For Windows users, this means you need to make one small change to your .ini file. For Linux users, this means that you'll have to recompile PHP once again.
If you are using the Windows version of PHP, you need to edit the php3.ini file (or php.ini if you are using PHP4) in C:\windows or C:\WINNT, depending on your operating system.
To enable PHP to work with MySQL, you need to uncomment the line that says "extension=php3_mysql.dll." To do this you need to delete the semicolon from in front of that line. The line should look like the one below.
;Windows Extensions extension=php3_mysql.dll
Now save the file and restart your Apache server, and you are all set to go.
If you are using Linux, you need to recompile your version of PHP. While this may take a few more minutes to set up than if you were using Windows, you'll once again have the satisfaction of turning a bunch of source code into a living, breathing program. After all, that's why you are a Linux user!
When you recompile, just follow the same steps you used in Chapter 1, only add the flagwith-mysql when you issue the configure command. This tells the PHP compile program to include the extra functions you'll need when connecting to the database.
After that, you'll need to stop and restart your Apache server for the changes to take effect.