The driver could not be found

0

I am learning to use Laravel 5.6.

I had AppServ installed with version of PHP 5.6 and for Laravel's requirements it is to have a version equal to or greater than 7.1.3, uninstall AppServ and download Xampp, which has the most current version of PHP. In addition to that, install Laravel through Composer and until then everything is fine.

The problem comes when I want to migrate with this command:

php artisan migrate

Answer that the driver does not exist but really does exist, since I already verify it in my phpinfo, my php.ini and the location of the modules in Xampp with the path that there is in php.ini, and everything fits, plus to execute a function to know if the module exists.

The error in particular is:

[Illuminate\Database\QueryException]
could not find driver: (SQL select * from information_schema.tables 
where tables_schema = appmarket and table_name = migrations)

Any other ideas?

    
asked by Hoose 07.03.2018 в 15:57
source

2 answers

0

I could not find the solution for Xampp or AppServ, so I followed Shaz's advice and installed Homestead.

When I downloaded Homestead everything was perfect until I used the vagrant up command and I missed an error. The problem is that vagrant can not run that route if it has special characters (this includes the username with which you log in to your computer too).

After that, when I try to execute php artisan migrate , I miss the following error:

[Illuminate\Database\QueryException]
[PDOException] SQLSTATE[HY000] [2002] Connection refused.

The problem was that Homestead created my file .env and the DB_HOST that it had by default was the 127.0.0.1 , when in fact it should have been 192.168.10.10 or the IP that you have put in your file Homestead.yaml .

With that I was able to do the migrations and I did not have any problems.

    
answered by 09.04.2018 / 18:34
source
0

In your .env file, you must have values like:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

Ensure that they correspond to your database.

If you have it right here, go to check in config / database.php

Find the code that you configure for mysql. It's something like:

'mysql' => [
    'read' => [
        'host' => '192.168.1.1',
    ],
    'write' => [
        'host' => '196.168.1.2'
    ],
    'sticky'    => true,
    'driver'    => 'mysql',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => '',
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix'    => '',
],

This example was taken from the official doc where you can also guide you to configure your connection.

It is also advisable to set the configuration values according to your .env file. For that you can use the helper env () . For example, to not place the password of the DB directly in the code (since anyone who accesses the code will have the credentials), you can use the following:

'password'  => env('DB_PASSWORD', 'my_default_password'),

What it will do is look in the .env file for the value of DB_PASSWORD and use it. If it can not be found, it will use the value of the second parameter as default.

I'm not sure if in 5.6 you can also put the DB by default using

'default' => env('DB_CONNECTION', 'mysql'),

You could try too.

Obviously before executing the command, make sure that the DB is active with XAMPP (since that is what you are using).

With this you should be able to run your migrations.

    
answered by 10.03.2018 в 16:45