Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What PDO driver to use with mariadb?

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.

like image 591
Question Overflow Avatar asked Jan 03 '14 07:01

Question Overflow


People also ask

Does PDO work with MariaDB?

Connecting to and communicating with an underlying MariaDB database is facilitated by the PDO extension.

Does PDO work with MySQL?

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.


2 Answers

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.

like image 155
Question Overflow Avatar answered Sep 29 '22 16:09

Question Overflow


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
like image 35
Dmitriy.Net Avatar answered Sep 29 '22 15:09

Dmitriy.Net