php artisan migrate throwing [PDO Exception] Could not find driver - Using Laravel

后端 未结 26 1406
眼角桃花
眼角桃花 2020-12-01 07:41

I have a bad experience while installing laravel. However, I was able to do so and move to the next level. I used generators and created my migrations. But when I type the

相关标签:
26条回答
  • 2020-12-01 07:49

    Ran into the same issue here, and turns out this is because PHP at the command line uses a different php.ini file from the browser version, which is why it looks like it's loading the extension correctly when you look at phpinfo() in a browser.

    As per this answer, you just need to run:

    php --ini
    

    At the command line, which will tell you the path to the currently loaded php.ini (probably actually a php-cli.ini file located in the same place as your regular php.ini file).

    Once you've found that, modify it with the pdo extensions you want (in this case for MySQL):

    extension=pdo_mysql.so
    

    Or, for any other users that are on Windows using some kind of WAMP server, it probably looks like this instead:

    extension=php_pdo_mysql.dll
    
    0 讨论(0)
  • 2020-12-01 07:51

    I was also getting the same error --> "[PDOException]
    could not find driver "

    After that I used many commands but not didn't get any help

    Finally I used the following command, which solved my problem.

    sudo apt-get install php5-sqlite

    0 讨论(0)
  • 2020-12-01 07:51

    If you are using Laravel 5.x, and the error is from trying to modify the attributes of a column, it is possible the error comes from a missing pre-requisite.

    Try this:

     composer require doctrine/dbal
    

    Then try running your migrations.

    From here: https://laravel.com/docs/master/migrations#modifying-columns

    0 讨论(0)
  • 2020-12-01 07:52

    In my case I wasn't aware that the PHP run by Apache was different from the one run by CLI. That might be the case if during configuration in httpd.conf you specified a PHP module, not being the default one your CLI uses.

    0 讨论(0)
  • 2020-12-01 07:53

    You must be installing the latest version of php mysql in my case I am install php7.1-mysql

    Try this

    sudo apt-get install php7.1-mysql
    

    I am using the latest version of laravel

    0 讨论(0)
  • 2020-12-01 07:54

    Please check your Laravel .env file also. Make sure DB_CONNECTION=mysql, otherwise it won't work with MySQL. It tried to load something else.

    0 讨论(0)
提交回复
热议问题