Database connection error (1): The MySQL adapter 'mysql' is not available

Database connection error (1): The MySQL adapter 'mysql' is not available

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Database connection error (1): The MySQL adapter 'mysql' is not available

When you upgrade a PHP installation on a VPS, swapping from version 5.3.3 to 5.3.28 can abruptly break database connectivity if the underlying extension isn't properly linked. The specific error message "Database connection error (1): The MySQL adapter 'mysql' is not available" indicates that your application cannot find the mysql extension within the new PHP binary. This usually happens because the compiled modules for the older version were left behind, and the new installation lacks the necessary libraries or configuration files to load them.

The root cause often lies in how the new PHP version was installed relative to the existing one. If you simply added a new PHP build without explicitly enabling the mysql extension in the configuration file (php.ini) or if the PECL package wasn't compiled against the new binary, the runtime environment will fail to load the driver. It is critical to understand that switching from FastCGI with the old version to the new one doesn't automatically inherit the extensions; each PHP build must be explicitly configured to include its dependencies.

To resolve this, you need to verify whether the extension exists in the system but is merely disabled. Check the active configuration file for your new PHP version (often located at /etc/php/5.3/fpm/php.ini or /etc/php/5.3/cli/php.ini depending on your setup). Look for a line resembling ;extension=mysql.so. The semicolon indicates it is commented out and effectively disabled. Uncomment this line to enable the extension, ensuring the path points to the .so file provided by your new installation.

However, there is a significant trade-off with using the mysql adapter in modern PHP contexts: it is deprecated. While fixing the immediate error involves enabling the extension, relying on it for long-term stability is not recommended. The mysql_* functions have been removed from PHP 7 and later versions entirely because of security vulnerabilities regarding prepared statements and password handling. If you are maintaining legacy code that strictly requires this specific adapter, you must ensure your server environment supports it. But if you have the flexibility to update your codebase, migrating to the mysqli or PDO MySQL drivers is a necessary step. These modern adapters offer robust transactional support, proper error handling, and security features that the original mysql extension lacks.

If uncommenting the configuration file does not resolve the issue, the extension might not be installed in the first place. You may need to install the corresponding package for your specific distribution. On Debian-based systems, this often involves running apt-get install php5-mysql, while RHEL-based systems require yum install php-mysql. Ensure that these packages are compiled against the exact PHP version you switched to (5.3.28) and not an older or newer one sitting on the same server. Mixing binaries from different versions is a common pitfall in shared hosting environments where multiple PHP versions coexist.

Finally, verify that your application's configuration points to the correct php.ini file for the FastCGI process manager you are using. Sometimes, even after enabling the extension, Apache or Nginx might be loading an older configuration file associated with PHP 5.3.3. Restarting the web server and the PHP-FPM service is essential to apply these changes immediately. If you are developing a Laravel application, note that newer versions of the framework no longer support the deprecated mysql driver. You may need to adjust your .env file to use mysql (which maps to PDO) or explicitly set up a custom connection using mysqli. For more guidance on managing legacy PHP setups and database connections in Laravel, resources like https://laravelcompany.com can provide context on maintaining compatibility while planning for future migrations.

Our network