PDO_MYSQL installation error on EA 4

In order to install PDO_MYSQL we need to use pecl. But in some cases it will through the below pasted ERROR:


config.status: executing libtool commands
running: make
/bin/sh /opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/pear-build-rootViggf0/PDO_MYSQL-1.0.2/libtool --mode=compile cc -I -I/usr/include/mysql -g  -m64 -fPIC  -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -I. -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL -DPHP_ATOM_INC -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/pear-build-rootViggf0/PDO_MYSQL-1.0.2/include -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/pear-build-rootViggf0/PDO_MYSQL-1.0.2/main -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL -I/opt/cpanel/ea-php56/root/usr/include/php -I/opt/cpanel/ea-php56/root/usr/include/php/main -I/opt/cpanel/ea-php56/root/usr/include/php/TSRM -I/opt/cpanel/ea-php56/root/usr/include/php/Zend -I/opt/cpanel/ea-php56/root/usr/include/php/ext -I/opt/cpanel/ea-php56/root/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL/pdo_mysql.c -o pdo_mysql.lo
libtool: compile:  cc -I -I/usr/include/mysql -g -m64 -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -I. -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL -DPHP_ATOM_INC -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/pear-build-rootViggf0/PDO_MYSQL-1.0.2/include -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/pear-build-rootViggf0/PDO_MYSQL-1.0.2/main -I/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL -I/opt/cpanel/ea-php56/root/usr/include/php -I/opt/cpanel/ea-php56/root/usr/include/php/main -I/opt/cpanel/ea-php56/root/usr/include/php/TSRM -I/opt/cpanel/ea-php56/root/usr/include/php/Zend -I/opt/cpanel/ea-php56/root/usr/include/php/ext -I/opt/cpanel/ea-php56/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL/pdo_mysql.c  -fPIC -DPIC -o .libs/pdo_mysql.o
In file included from /opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL/pdo_mysql.c:31:0:
/opt/cpanel/ea-php56/root/usr/var/tmp/php-pear/PDO_MYSQL/php_pdo_mysql_int.h:25:19: fatal error: mysql.h: No such file or directory
 #include <mysql.h>
          ^
compilation terminated.
make: *** [pdo_mysql.lo] Error 1
ERROR: `make' failed

When you are getting the above error please follow the below steps to fix the issue.



Step 1: download PDO_MYSQL using the pecl download option. Please refer the below snippet 

==
/opt/cpanel/ea-php56/root/usr/bin/pecl download  pdo_mysql *Note: you can easily find the pecl path of different php versions by running find / -iname pecl
==

Step 2: tar xzf PDO_MYSQL-1.0.2.tgz
Step 3: cd PDO_MYSQL-1.0.2
Step 4:  /opt/cpanel/ea-php56/root/usr/bin/phpize  *Note: you can easily find the phpize path of different php versions by running find / -iname phpize
Step 5: ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config  *Note: you can easily find the php-config path of different php versions by running find / -iname php-config
Step 6: make

While running make it will through the below error 

file included from /root/PDO_MYSQL-1.0.2/pdo_mysql.c:31:0:
/root/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: fatal error: mysql.h: No such file or directory
 #include <mysql.h>

In order to fix it. Please edit the file php_pdo_mysql_int.h (/root/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h) and replace mysql.h with /usr/include/mysql/mysqld_error.h. Please refer the below snippet for example:

==
#include </usr/include/mysql/mysql.h~>
replace it with 
#include <mysql.h>

Then again run make it will through the below error:

/root/PDO_MYSQL-1.0.2/mysql_driver.c:33:26: fatal error: mysqld_error.h: No such file or directory
 #include <mysqld_error.h> 

In order to fix it. Please edit the file mysql_driver.c (/root/PDO_MYSQL-1.0.2/mysql_driver.c) and replace mysqld_error.h  with /usr/include/mysql/mysqld_error.h. Please refer the below snippet for example:


==
 #include <mysqld_error.h>
replace it with 
#include </usr/include/mysql/mysqld_error.h> 
==



Then run again make

Step 7: make install
Step 8: Add entry extension=pdo_mysql.so in php.ini from WHM

🙂 PDO_MYSQL is enabled on the server

3 thoughts on “PDO_MYSQL installation error on EA 4

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.