How to install MySQLi on MacOS

To install MySQLi on a Mac, you will first need to install the MySQL database server on your machine. You can download the MySQL installer from the MySQL website ( and run it to install MySQL.

Once MySQL is installed, you can use the mysqli extension to connect to MySQL from PHP. To do this, you will need to have PHP installed on your machine. If you don't have PHP installed, you can install it using one of the following methods:

  1. Use Homebrew:
    1. Open a terminal and run the command brew update. This will update the list of available packages.
    2. Run the command brew install php. This will install PHP on your machine.
  2. Install PHP using the package installer:
    1. Download the PHP package installer from the PHP website (
    2. Double-click the downloaded .pkg file to open the package installer.
    3. Follow the prompts to install PHP on your machine.

Watch a course Learn object oriented PHP

Once PHP is installed, you can use the phpinfo() function to check if the mysqli extension is enabled. To do this, create a file called phpinfo.php in your web server's root directory with the following contents:


Then, open a web browser and navigate to http://localhost/phpinfo.php. This will display a page with information about your PHP installation, including a list of enabled extensions. Look for the mysqli extension in the list. If it is present and enabled, then MySQLi is installed and ready to use. If it is not present, you may need to enable it by adding the following line to your php.ini file:


Then, restart your web server to apply the changes. You should now be able to use MySQLi to connect to MySQL from PHP.