3.1 Installing and Configuring

You must download and install MySQL 4.1 or greater to use mysqli. In particular, if you use the MySQL library bundled with PHP 4, you now must download and install a new version of MySQL.

While PHP 4 bundles a copy of the MySQL client libraries, PHP 5 does not. As of MySQL 4.1, the entire MySQL application is licensed under the GNU General Public License (GPL). Since PHP uses a different type of open source license, PHP was legally unable to bundle the libraries without modifying their license.

MySQL eventually added a special license exemption for many free and open source products, including PHP. However, the PHP Group decided not to restore the libraries. Since many people already had the libraries on their systems, bundling the libraries actually caused conflicts when the bundled library differed from the preinstalled version.

As a result, if you don't already have a copy of the MySQL client libraries, you need to install one. You can download MySQL from http://www.mysql.com/. If you're using mysqli, be sure to use a copy of MySQL 4.1.2 or greater, as earlier versions won't work with PHP.

Before installing MySQL 4.1, you should read the Section 3.10. You may have migration problems, particularly if you're upgrading directly from MySQL 3.2.x and skipping MySQL 4.0. Reading this section isn't necessary if MySQL 4.1 is your first version of MySQL.

After you've installed MySQL, you can enable the mysqli extension with the --with-mysqli flag during the PHP configure process.

Unlike for mysql, you don't tell PHP where MySQL is located by adding the path to the MySQL base installation. Instead, PHP uses MySQL's new mysql_config file.

Here's an example of the difference between the configuration options for mysql and mysqli for a MySQL installation in /usr/local/mysql:

// mysql


// mysqli


You can enable both mysql and mysqli at the same time, which is useful when you need to support legacy applications. You should link PHP against the same set of MySQL libraries to prevent compiler errors.