Could not find driver while migrating on Laravel 4

2019-04-11 09:48发布

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.

2条回答
贪生不怕死
2楼-- · 2019-04-11 09:54

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

查看更多
做自己的国王
3楼-- · 2019-04-11 10:15

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

查看更多
登录 后发表回答