Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

weakprotos's avatar

Ubuntu 14.04.2 Laravel 4.2.0 PDOException could not find driver MySQL

I want Laravel 4.2.0 working on my Ubuntu 14.04.2 LTS Server.

What I have done until now:

  1. Installing Ubuntu 14.04.2

  2. sudo apt-get install apache2

  3. sudo apt-get install mysql-server

  4. Install Openssl

  5. Install libmcrypt

  6. Install PHP by

        ./configure --with-openssl --with-mcrypt --enable-mbstring --with-pdo-mysql --enable-pdo --with-mysql
    

    make make install

  7. Download Laravel 4.2.0 zip file from GitHub, unzip and transfer it through WinSCP

  8. Install Laravel 4.2.0 by

    curl -sS https://getcomposer.org/installer | php
    php composer.phar install
    
  9. Database connection by configuring /app/config/database.php

    'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laravel', 'username' => 'laravel-user', 'password' => '************', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),

And I got this error.

PDOException
could not find driver

Open: /var/www/laravel/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
     */
    public function createConnection($dsn, array $config, array $options)
    {
        $username = array_get($config, 'username');
 
        $password = array_get($config, 'password');
 
        return new PDO($dsn, $username, $password, $options);
    }
 

I don't know what to do. I have googled for a day, and got no answer. Please help me.

I checked theres PDO enabled with php -i|grep PDO command.

Result:

PDO support => enabled
PDO drivers => sqlite, mysql
PDO Drivers for MySQL => enabled
PDO Drivers for SQLite 3.x => enabled

But I checked php.ini, there's no line like extension=pdo.so So I added the lines like this

[Pdo]
; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off"
; http://php.net/pdo-odbc.connection-pooling
;pdo_odbc.connection_pooling=strict

;pdo_odbc.db2_instance_name

[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so

Please help me out of this frustrating situation.. Thank you in advance for helping me.

0 likes
10 replies
weakprotos's avatar

migration is okay but I got POE exception error when I view the webpage

weakprotos's avatar

thank you, Do you mean reinstall everything? Or just laravel?

bashy's avatar

"Could not find driver" means it can't find the PDO driver connector to connect to MySQL.

Doesn't look like you have that enabled? I have mine setup in files (with priority) /etc/php5/fpm/conf.d/20-pdo_mysql.ini

; configuration for php MySQL module
; priority=20
extension=pdo_mysql.so
weakprotos's avatar

my pdo setting was right

It is just lilke this

; configuration for php MySQL module
; priority=20
extension=pdo_mysql.so

It is now solved, I just reinstalled laravel 4.2 application.

My problem was install PDO after Laravel 4.2.

PDO should be installed before Laravel 4.2

Thank you for helping me.

bashy's avatar

Sure you restarted PHP/Nginx (or Apache) after installing it? It should work even if you have an app already running.

javipedrera's avatar

Same to me, I reinstalled php5.6-mysql and now it is working.

1 like
Muhammad-Ateek's avatar

javipedrera you solved my problem. i track it by followinf command php -i|grep PDO it was showing follwing results in terminal. PDO PDO support => enabled PDO drivers => and when i run sudo apt-get install php5.6-mysql i got follwing result and it solved my problem. PDO PDO support => enabled PDO drivers => mysql PDO Driver for MySQL => enabled

abaam's avatar

Thank to you Muhammad-Ateek.

So may problem is I upgraded my PHP to 5.6 under AWS Ubuntu, i got the same error. The solution is to install this "sudo apt-get install php5.6-mysql" , this contains the driver for the PDO for PHP5.6 for the communication of PHP-MYSQL

Please or to participate in this conversation.