Waiyl Karim
Waiyl Karim

Reputation: 2950

Could not find driver while migrating on Laravel 4 using XAMPP Server Linux (Ubuntu)

I have installed Laravel 4.1 everything worked just fine, but when I try to use migration it throws a PDO Exception saying:

[PDOException] could not find driver

I found many answers on StackOverFlow, but none of them solved my problem, unfortunately.

I have tried to enable pdo extension and pdo_mysql extension, but it says that pdo is already loaded. I have tried to reinstall PDO and PDO MySQL but nothing worked.

I am using XAMPP Server on a Ubuntu 64bit machine.

Thank you in advance.

Upvotes: 3

Views: 2873

Answers (2)

Jose Philip Raja
Jose Philip Raja

Reputation: 188

If you are looking for simple solution, I had same issue & this worked for me..

When you run php artisan from terminal, you invoke php5-cli package.

To run artisan with XAMPP's php you need to use:

/opt/lampp/bin/php artisan migrate

But make sure your /opt/lampp/etc/php.ini is properly configured to enable pdo_mysql

Upvotes: 4

Waiyl Karim
Waiyl Karim

Reputation: 2950

The problem is solved!

Steps:

  1. Uninstall XAMPP

  2. apt-get update && apt-get install lamp-server^

  3. apt-get autoremove apache2

  4. apt-get remove --purge mysql-server mysql-client mysql-common

  5. apt-get autoremove && apt-get update && apt-get install php5-mysql && apt-get install pdo-mysql

  6. Install XAMPP

However, I had a new problem with running php artisan then I discovered that I had to run /opt/lampp/bin/php artisan instead of php artisan

Upvotes: 3

Related Questions