comment 0

pecl install mysqlnd_ms – make: *** [php_mysqlnd_ms.lo] Error 1

This error will occur when you try to install mysqlnd_ms using pecl on PHP v5.6 and above. This is because the pecl package manager hasn’t been updated yet, thats why the extension for mysqlnd_ms is available only for PHP v5.3 to PHP v5.5 ( correct me if I’m wrong 😛 ).

What is mysqlnd_ms?

If you are reading this post, then you probably know what is mysqlnd_ms and what it is for. So if you want to go ahead and skip to the solution part, click here. But if you don’t know what is mysqlnd_ms, continue reading…

Mysqlnd_ms is an extension under MySQL Native Driver (mysqlnd) that promotes High Availability for Mysql Connection.

Here are the Key Features of mysqlnd_ms:

Transparent and therefore easy to use.

  • Supports all of the PHP MySQL extensions.
  • SSL support.
  • A consistent API.
  • Little to no application changes required, dependent on the required usage scenario.
  • Lazy connections: connections to master and slave servers are not opened before a SQL statement is executed.
  • Optional: automatic use of master after the first write in a web request, to lower the possible impact of replication lag.

Can be used with any MySQL clustering solution.

  • MySQL Replication: Read-write splitting is done by the plugin. Primary focus of the plugin.
  • MySQL Cluster: Read-write splitting can be disabled. Configuration of multiple masters possible
  • Third-party solutions: the plugin is optimized for MySQL Replication but can be used with any other kind of MySQL clustering solution.

Featured read-write split strategies

  • Automatic detection of SELECT.
  • Supports SQL hints to overrule automatism.
  • User-defined.
  • Can be disabled for, for example, when using synchronous clusters such as MySQL Cluster.

Featured load balancing strategies

  • Round Robin: choose a different slave in round-robin fashion for every slave request.
  • Random: choose a random slave for every slave request.
  • Random once (sticky): choose a random slave once to run all slave requests for the duration of a web request.
  • User-defined. The application can register callbacks with mysqlnd_ms.
  • PHP 5.4.0 or newer: transaction aware when using API calls only to control transactions.
  • Weighted load balancing: servers can be assigned different priorities, for example, to direct more requests to a powerful machine than to another less powerful machine. Or, to prefer nearby machines to reduce latency.

Global transaction ID

  • Client-side emulation. Makes manual master server failover and slave promotion easier with asynchronous clusters, such as MySQL Replication.
  • Support for built-in global transaction identifier feature of MySQL 5.6.5 or newer.
  • Supports using transaction ids to identify up-to-date asynchronous slaves for reading when session consistency is required. Please, note the restrictions mentioned in the manual.
  • Throttling: optionally, the plugin can wait for a slave to become “synchronous” before continuing.

Service and consistency levels

  • Applications can request eventual, session and strong consistency service levels for connections. Appropriate cluster nodes will be searched automatically.
  • Eventual consistent MySQL Replication slave accesses can be replaced with fast local cache accesses transparently to reduce server load.

Partitioning and sharding

  • Servers of a replication cluster can be organized into groups. SQL hints can be used to manually direct queries to a specific group. Grouping can be used to partition (shard) the data, or to cure the issue of hotspots with updates.
  • MySQL Replication filters are supported through the table filter.


Check mysqlnd_ms documentation for more info.


Now back to the real topic. 😀

How to install mysqlnd_ms in PHP v5.6 and above

First you need to install the dependencies.

If you are using php-mysql, then you should remove it and replace it with php-mysqlnd and restart your apache. Please see commands below:

CentOS, Fedora, etc.

yum remove -y php-mysql 
yum install -y php-mysqlnd
service httpd restart

Ubuntu, Debian, etc

apt-get remove -y php-mysql
apt-get install -y php-mysqlnd
apachectl restart

Now check if mysqlnd module is already loaded by typing this command

php -m


php -m | grep mysqlnd

mysqlnd should appear when you enter this command if mysqlnd is loaded.

Now let’s install other dependencies by typing the command below:

CentOS, Fedora, etc.

sudo yum install -y php-pear php-devel

Ubuntu, Debian, etc

sudo apt-get install -y php-pear php-dev

Now let’s install mysqlnd_ms:

svn checkout && cd trunk && phpize && ./configure --with-php-config=/usr/bin/php-config && make
sudo make install
sudo echo "" >> /etc/php.ini

Then verify if mysqlnd_ms is properly installed by entering this command.

php -m | grep mysqlnd_ms

NOTE: Package names maybe different on some repos. Please modify the commands according to your needs. 😀

Please comment your questions, or if you encounter a problem during the installation. Have fun!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *