Cannot install php-mysqli extension on Centos

Cannot install php-mysqli extension on Centos

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

Stefan Bogdanescu

Founder & Senior Architect

Cannot install php-mysqli extension on Centos

Running yum install php-mysqli on a CentOS system is a straightforward request, yet the output often reveals a frustrating conflict between two MySQL-related packages. The error log you are seeing indicates that the mysql-libs-5.1.71 package is attempting to overwrite files owned by MySQL55-server-5.5.34. Specifically, character set definition files like Index.xml, README, and various charset XML files (e.g., armscii8.xml, ascii.xml) are colliding in the /usr/share/mysql/charsets/ directory.

This is not a simple dependency issue; it is a version mismatch between the library package and the server package. The mysql-libs package contains client libraries and shared resources, while the MySQL55-server package expects a specific set of these resources tailored to version 5.5. When you run the install command, yum detects that installing the library would break the existing server installation's file integrity, so it aborts the transaction.

The root cause usually stems from a legacy environment where multiple MySQL versions have been installed side-by-side in an unmanaged state, or where the base system packages are outdated relative to the custom server build. In many older CentOS setups (such as CentOS 6), the default repository might offer mysql-libs version 5.1, while your application stack relies on a newer MySQL 5.5 instance installed from a third-party repository.

To resolve this, you must align the versions or remove the conflicting component. The most direct approach is to ensure that only one set of MySQL libraries and servers exists on the system. If you are not actively using MySQL 5.1 for client connections, you can attempt to replace the conflicting library package with a version that matches your server.

First, identify the exact version required by your active server instance. Since your error log explicitly mentions MySQL55-server-5.5.34, you likely need mysql-libs compatible with MySQL 5.5. If your repository provides it, force an update:

yum install mysql-libs-mysql55-server

If such a specific package does not exist in your repo, you may need to remove the conflicting library entirely if no other application depends on it. Be cautious, as mysql-libs is often a dependency for other tools like mysqldump or PHP's mysql_* functions (if installed separately).

yum remove mysql-libs

After removing the conflict, retry the original command:

yum install php-mysqli

Alternatively, if you are using a custom repository that provides both the server and the libraries but they are mismatched, consider updating to the latest versions available in that repo. This often resolves version skew issues automatically.

Another viable path is to switch to the official MySQL YUM repository, which ensures that mysql-server, mysql-libs, and php-mysqli are all compiled against compatible headers and libraries. This eliminates the risk of file conflicts caused by mixing third-party builds with system packages.

Once the package manager confirms success, verify that the extension is loaded:

php -m | grep mysqli

If nothing appears, check the php.ini configuration file located in /etc/php.d/ or /etc/php.ini. The extension might be present but commented out. Uncomment the line:

extension=mysqli

Restart Apache or PHP-FPM if you are using a web server, then reload the page or re-run your script to confirm connectivity.

In modern environments, relying on official repositories and maintaining consistent package versions across the stack is essential to avoid these file ownership conflicts. If you find yourself repeatedly encountering version mismatches, consider migrating to a supported long-term release (LTS) where upstream packages are more stable and less prone to such fragmentation.

Our network