Laravel Migration Error :: PDOException, Could not find driver

…衆ロ難τιáo~ 提交于 2019-12-20 06:39:02

问题


I am trying to make a laravel and stucked when migration. when i enter php artisan migrate in terminal, showing PDOException error. attaching my screenshot of terminal and phpinfo.

What i sthis issue, How can i solve this,

I am using Xampp.

Anybody please help me.

Thanks


回答1:


Try re-installing Xampp? You could use Laravel homestead for a virtual machine, it makes sure you have the proper PHP version and the required dependencies needed to install and avoids having to run Xampp or MAMP or WAMP or any of the amps.

It looks like Xampp cannot find: /usr/lib/php5/20121212/php_pdo_mysql.dll, so make sure that file exists.

You may need to re-install PHP PDO on your machine, refer to: http://php.net/manual/en/pdo.installation.php

Also per PHP docs:

PDO and all the major drivers ship with PHP as shared extensions, and simply need to be activated by editing the php.ini file:

extension=php_pdo.dll




回答2:


Please check you have installed more than one php version in your system, one is running for web server and another for php CLI, using PHP_INFO for web and php --ini in commandline, if different version found then upgrade or downgrade means make it one version configuration, and make sure PDO is enable in your system.

From php5.6 to php7.0:

    Apache:

    sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart

    CLI:

    sudo update-alternatives --set php /usr/bin/php7.0

From php7.0 to php5.6:

    Apache:

    sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

    CLI:

    sudo update-alternatives --set php /usr/bin/php5.6


来源:https://stackoverflow.com/questions/29104619/laravel-migration-error-pdoexception-could-not-find-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!