skip to Main Content

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

IlluminateDatabaseQueryException 

  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
      IlluminateFoundationConsoleKernel::handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))

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,
        ],

    ],

3

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. “lcrud” database exist ?

    or

    php artisan config:clear
    php artisan cache:clear
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search