MySQL or MySQLi are used to connect to the database of a site. The mysqli_connect() function in PHP is used to connect a site to the database. In previous versions of PHP, mysql_connect() was used for connection. As mysql_connect() is now deprecated and mysqli_connect() was previously unavailable, errors on the site in regards to either function are typically related to a mismatched PHP version. This guide will cover some common error messages and how to correct the error.
Common Error Messages
Error: Failed to start application: The MySQLi extension for PHP is not installed or enabled.
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
SQL ERROR [ mysql4 ]
mysql_connect function does not exist, is mysql extension installed?
An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
Checking the PHP Version
- Log into cPanel
- Navigate to MultiPHP Manager, located in the Software section
- If the error references mysql or mysql_connect, change the current PHP version to version 5.6 or lower
TIP: If updates are available for the website, such as with WordPress, updating the site can both clear this error as well as make the site more secure.
IMPORTANT: If the required version of PHP is missing on VPS+ hosting, it can be installed in EasyApache4. - If the error references mysqli or mysqli_connect, change the current PHP version to version 7.0 or higher
IMPORTANT: If on VPS+ hosting and the error persists, please proceed to Installing the MySQL/MySQLi Extension. - If the error references mysql or mysql_connect, change the current PHP version to version 5.6 or lower
Installing the MySQL/MySQLi Extension
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
NOTE: In some cases, the MySQL or MySQLi extension may not have been installed for the version of PHP the site is on. In these cases, it can be installed through EasyApache 4 in Root WHM.
- Log into Root WHM
- Navigate to EasyApache 4 in the Software section
- Select Customize on the Currently Installed Packages
- Navigate to PHP Extensions
- Search for mysql in PHP Extensions
- Select the correct php-mysqlnd extension to install by clicking on the toggle
TIP: Extensions can also be uninstalled by deselecting the toggle. - Select Review to review the selected extensions to install
- Select Provision to begin installing the required extensions
- Once provisioning is complete, EasyApache will display "The provision process is complete."
EXAMPLE:
NOTE: This process can sometimes take several minutes.
Comments
0 comments
Article is closed for comments.