1

i am new to php laravel i try to migrate project with database but i got following error ?

Illuminate\Database\QueryException 

  could not find driver (SQL: select * from information_schema.tables where table_schema = lcrud and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
    665|         // If an exception occurs when attempting to run a query, we'll format the error
    666|         // message to include the bindings with SQL, which will make this exception a
    667|         // lot more helpful to the developer instead of just the database's errors.
    668|         catch (Exception $e) {
  > 669|             throw new QueryException(
    670|                 $query, $this->prepareBindings($bindings), $e
    671|             );
    672|         }
    673| 

      +34 vendor frames 
  35  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

and here is the .env file

APP_NAME=lcrud
APP_ENV=local
APP_KEY=base64:PchgVozhfLeJtzlwFMtY0VGEpsfj2PYCtS7eVcothEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lcrud
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

i have double check that my password is nothing so i have tried to place empty string like this DB_PASSWORD='' and also like this DB_PASSWORD=' ' but it does not work also in other stackoverflow question i read about php.ini file and made changes according this page.

my php version is PHP 7.2.24-0ubuntu0.19.04.2 (cli) (built: Jan 14 2020 13:26:02) ( NTS )

and when i type which php in terminal i got /usr/bin/php

i was trying other question answer but not working . Please help me , Thank You .

UPDATE here i have my database.php file that might help you ,

'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

    ],
Kiran Patel
  • 98
  • 3
  • 12
  • I think [this](https://stackoverflow.com/questions/46745365/artisan-migrate-could-not-find-driver) will help you. It has already answered. – Ragib Huda Mar 17 '20 at 05:35
  • @RagibHuda thanks but i have already tried this , i have already given this link in my question but again thank you . – Kiran Patel Mar 17 '20 at 05:42

3 Answers3

1

You get this error because there is no mysql server driver. you can try it by install it with use of below commands.

sudo apt-get install mysql-server php7.1-mysql
sudo service apache2 restart
sudo service mysql restart

Hope this will help you.

Rajdip Chauhan
  • 345
  • 2
  • 11
  • i get this error when i type sudo apt-get installl mysql-server php7.1-mysql E: Unable to locate package php7.1-mysql E: Couldn't find any package by glob 'php7.1-mysql' E: Couldn't find any package by regex 'php7.1-mysql' – Kiran Patel Mar 17 '20 at 10:19
1

"lcrud" database exist ?

or

php artisan config:clear
php artisan cache:clear
Waleed Muaz
  • 737
  • 6
  • 17
0

I think can you missing php7.x-mysql

You can run:

php -v

For example Output: PHP 7.1

sudo apt-get install php7.1-mysql

Update: PHP 7 is not available for Ubuntu Trusty in the standard Ubuntu repositories (2016-01-02). You could use the PPA ppa:ondrej/php.

sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1-fpm
sudo apt-get install php7.1-mysql
sudo service apache2 restart
Dinh Luong
  • 127
  • 3
  • 15
  • it shows me this E: Unable to locate package php7.1-mysql E: Couldn't find any package by glob 'php7.1-mysql' E: Couldn't find any package by regex 'php7.1-mysql' – Kiran Patel Mar 17 '20 at 05:41
  • PHP 7 is not available for Ubuntu Trusty in the standard Ubuntu repositories (2016-01-02). You could use the PPA ppa:ondrej/php. `sudo apt-add-repository ppa:ondrej/php`, next `sudo apt-get update`, next `sudo apt-get install php7.1-fpm` and `sudo apt-get install php7.1-mysql` – Dinh Luong Mar 17 '20 at 06:03
  • @QuốcDinh that comment is useful but comments tend to get lost here, I'd recommend editing the answer to include that information – Darren H Mar 17 '20 at 07:02