After replacing mysql with mariadb, I encountered the following error:
PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /var/www/inlcude/config.php:5\nStack trace:\n#0 /var/www/inlcude/config.php(5): PDO->__construct('mysql:dbname=my...', 'apache', 'ABCDE...')\n#1 /var/www/html/index(21): require('/var/www/inlcude/con...')\n#2 {main}\n thrown in /var/www/inlcude/config.php on line 5
I have read through the following two related questions, but can't find the answer there:
PDO and MariaDB
PDOException “could not find driver”
yum list pdo_mysql
, yum list php5-mysql
, yum list php5-mariadb
all returns no matching package. What is the name of the PDO driver for mariadb to be used on Fedora 20 (red hat)?
Just to add, php-pdo
is already installed.
Connecting to and communicating with an underlying MariaDB database is facilitated by the PDO extension.
PDO will work on 12 different database systems, whereas MySQLi will only work with MySQL databases. So, if you have to switch your project to use another database, PDO makes the process easy. You only have to change the connection string and a few queries.
By trial and error, it turns out that I need to install mysqlnd to get the PDO driver.
yum install php-mysqlnd
Don't ask me why or how it works because I have absolutely no idea.
MarriaDB is branch of mysql. For installation PDO driver for it, install php-pdo and php-mysql packages
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
And after this you can install pdo and mysql from remi repositories
yum --enablerepo=remi install php-pdo
yum --enablerepo=remi install php-mysql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With