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

后端 未结 26 1405
眼角桃花
眼角桃花 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:43

    Install it via this command

    sudo apt-get install php5-gd

    this worked for me.

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

    I had this problem on debian. The issue was, I was using the dotdeb repository for more recent PHP packages. For some reason, it updated the php cli to 7.0, while the web php binary remained php 5.6. I used this answer to link the php command line binary to the 5.6 version, like so:

    $ sudo ln -sfn /usr/bin/php5 /etc/alternatives/php
    
    0 讨论(0)
  • 2020-12-01 07:46

    I think you missed the mysql driver for php5. Execute below command:

    sudo apt-get install php5-mysql
    /etc/init.d/php5-fpm restart
    
    0 讨论(0)
  • 2020-12-01 07:47

    You need to specifically enable the pdo_mysql plugin. Assuming you're using a standard PHP installation, then generally you would simply need to add this to your PHP.ini file:

    extension=pdo_mysql.so
    

    You need to ensure that this file exists in the extension directory though.

    Adding pdo_pgsql.so doesn't help because that is for PostgreSQL.

    Additionally, you should ensure that you restart the web-server after you make the changes to the PHP ini file, as the changes may not be reflected otherwise.

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

    I found the proper solution for this error! Either you don't have any database installed or your default database in this file config/database.php is set to some other database like this

    'default' => 'sqlite',
    'default' => env('DB_CONNECTION', 'sqlite'), //laravel 5.2
    

    change the default to which one you have installed or install that database which is made to be default! I had installed mysql and php artisan migrate worked after i changed that line to this:

    'default' => 'mysql',
    'default' => env('DB_CONNECTION', 'mysql'), //laravel5.2
    
    0 讨论(0)
  • 2020-12-01 07:48

    Laravel Testing with sqlite needs php pdo sqlite drivers

    For Ubuntu 14.04

    sudo apt-get install php5-sqlite
    sudo service apache2 restart
    

    In ubuntu 16.04 there is no php5-sqlite

    sudo apt-get install php7.0-sqlite
    sudo service apache2 restart
    
    0 讨论(0)
提交回复
热议问题