I have a problem using Laravel 5. When I run "php aritsan migrate", I got this error
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? [y/N] y
[PDOException]
could not find driver
I could run the application, but when database connection needed, I got this error
PDOException in Connector.php line 55:
could not find driver
in Connector.php line 55
at PDO->__construct('mysql:host=localhost;dbname=mydb', 'root', '', array('0', '2', '0', false, false)) in Connector.php line 55
at Connector->createConnection('mysql:host=localhost;dbname=mydb', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'mydb', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 22
How to fix it?
If your database is PostgreSQL and you have php7.2 you should run the following commands:
sudo apt-get install php7.2-pgsql
and
php artisan migrate
sudo apt-get update
For Mysql Database
sudo apt-get install php-mysql
For PostgreSQL Database
sudo apt-get install php-pgsql
Than
php artisan migrate
I'm using Ubuntu 16.04 and PHP 5.6.20
After too many problems, the below steps solved this for me:
find php.ini
path via phpinfo()
uncomment
extension=php_pdo_mysql.dll
add this line
extension=pdo_mysql.so
then run
sudo apt-get install php-mysql
It will depend of your php version. Check it running:
php -version
Now, according to your current version, run:
sudo apt-get install php7.2-mysql
Same thing happend to me after upgrading distro.
Running sudo apt-get install php7.0-mysql
fixed it for me.
For me the problem was that I was running the migrate command not from inside the container where php was running. The extension was properly set there but not at my host machine.
I have tried the following command on Ubuntu and its working for me
sudo apt-get install php7.0-mysql
Thanks
Source: Stackoverflow.com