Take the State of PHP 2026 Survey →

Remove support for libmysql from mysqli View as Markdown

Implemented (PHP 8.2)
Authors
Kamil Tekiela, dharman@php.net
Date
2022-01-06
Version
1
Target
PHP 8.2
Implementation
https://github.com/php/php-src/pull/7889
Source
wiki.php.net/rfc/mysqli_support_for_libmysql

Vote

Remove support for libmysql from mysqli closed
Yes
30
No
0
30 voters
alec Yes 2022-01-22 18:49
asgrim Yes 2022-01-22 19:41
ashnazg Yes 2022-01-26 14:18
cmb Yes 2022-01-23 22:18
cpriest Yes 2022-01-31 16:14
crell Yes 2022-01-23 16:11
cschneid Yes 2022-01-22 22:13
dharman Yes 2022-01-22 18:38
gasolwu Yes 2022-01-25 01:25
geekcom Yes 2022-01-28 19:58
girgias Yes 2022-01-27 16:27
irker Yes 2022-01-23 12:20
jbnahan Yes 2022-01-22 20:41
jhdxr Yes 2022-01-25 16:14
kalle Yes 2022-01-22 19:52
kguest Yes 2022-01-24 23:29
kocsismate Yes 2022-01-22 20:32
marandall Yes 2022-01-22 18:56
mauricio Yes 2022-01-23 19:26
mbeccati Yes 2022-01-24 08:41
ocramius Yes 2022-01-22 19:17
patrickallaert Yes 2022-01-25 21:53
reywob Yes 2022-01-24 16:07
santiagolizardo Yes 2022-01-23 18:42
sebastian Yes 2022-01-23 08:10
sergey Yes 2022-01-22 20:17
svpernova09 Yes 2022-01-22 19:43
theodorejb Yes 2022-01-23 03:12
tstarling Yes 2022-01-25 04:29
twosee Yes 2022-01-23 16:08

Discussions on the mailing list

Drop support for libmysql with mysqli
by Kamil Tekiela · 3 messages
RFC: Remove support for libmysql from mysqli
by Kamil Tekiela · 2 messages
[VOTE] RFC: Remove support for libmysql from mysqli
by Kamil Tekiela · 4 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:50 UTC

At the moment both mysqli and PDO_mysql support building against mysqlnd and libmysql. The default is mysqlnd since PHP 5.4. Mysqlnd is the recommended driver to be used with PHP.

Introduction

There are plenty of differences between the two drivers. Removing support for libmysql would allow PHP to simplify the code and unit tests. Advantages of mysqlnd include:

  • Bundled with PHP
  • Uses PHP memory management which helps to monitor memory usage and
  • improve performance
  • Provides functions that make life easier, e.g. get_result
  • Returns numeric values using PHP native types
  • The functionality does not depend on the version of the external library
  • Optional plugin functionality
  • Asynchronous queries

Advantages of libmysql:

  • Auto-reconnect is possible (this functionality is intentionally not supported by mysqlnd due to how dangerous it is)
  • LDAP and SASL authentication modes A PR exists to add this functionality to mysqlnd

However, libmysql has many disadvantages:

  • It does not use PHP memory model. It doesn't respect the memory limits, does not count towards memory stats and cannot utilize internal optimizations
  • PHP does not know the value size and needs to allocate as much memory as the field length. This makes it very difficult to use with long columns like LONGTEXT
  • Doesn't support get_result, bind-in-execute, and fetch_all & next_result (prior to PHP 8.1). This makes libmysql the smallest common denominator for applications like DBALs which can't rely on these easy to use functions and instead have to perform strange workarounds resulting in more complex code and worse performance, even when not using libmysql
  • Functionality differs from version to version. Depending on which libmysql version PHP was compiled with you might be able to use a certain feature or not.
  • Many failing tests. Some of these tests could be fixed with SKIP or conditional checks, but some fail because of incompatibilities.
  • Memory leaks. These might even be considered security vulnerabilities
  • Not available on Windows

While many distributions offer PHP with mysqlnd as default there are some that make it confusing for new users. In particular, when using cPanel, users are confused about how to enable mysqli with mysqlnd. Instead of enabling mysqli they have to enable nd_mysqli extension which is counterintuitive.

Making it possible to build mysqli against external libraries with limited functionality is confusing and unnecessary.

Proposal

The proposal is to remove the support for building mysqli against libmysql in the next version. As mysqlnd is the default option, most users should not observe any difference.

As of PHP 8.2, it will not be possible to link mysqli against any version of libmysql. If the option --with-mysqli will be supplied, mysqli will be built with mysqlnd.

Backward Incompatible Changes

It will not be possible to build mysqli against libmysql anymore. Any functionality that was only available with libmysql will have to be added to mysqlnd as a feature request. We will not add auto-reconnect, which means that users relying on this feature will have to find other ways.

Proposed PHP Version(s)

The change is proposed to go into PHP 8.2.

RFC Impact To Existing Extensions

Only mysqli extension will be affected.

Unaffected PHP Functionality

PDO_MySQL and PECL-mysql are not affected and can still be compiled against both drivers.

The PHP native driver (mysqlnd) will still be mostly compatible with libmysql and no further divergence in functionality is foreseen to happen.

Future Scope

This RFC does not deal with libmysql support in PDO_MySQL, although it might also be removed in future. At the moment, there are no arguments speaking against it.

Proposed Voting Choices

Voting started on 2022-01-22 and ends on 2022-02-05.

Vote: Remove support for libmysql from mysqli — Yes: 30 · No: 0 (closed)

Patches and Tests

https://github.com/php/php-src/pull/7889

References

Discussion on externals: https://externals.io/message/116730Reddit thread: https://www.reddit.com/r/PHP/comments/rt6y87/drop_libmysql_support_for_mysqli/