Laravel Migate Illuminate Database QueryException Could not find driver

How to Fix Error in Laravel Artisan Migrate on Ubuntu

Could Not Find Driver Php Mysql

php artisan migrate  Illuminate\Database\QueryException -  One of the excellent features of Laravel is the presence of a tool called Artisan. With Artisan , capabilities to create a database via  terminal.



When this article was written I encountered an error when I wanted to make a database migration. The error  is:

> php artisan migrate

   Illuminate\Database\QueryException 

  could not find driver (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:692
    688// If an exception occurs when attempting to run a query, we'll format the error
    689// message to include the bindings with SQL, which will make this exception a
    690// lot more helpful to the developer instead of just the database's errors.
    691catch (Exception $e) {
  ➜ 692throw new QueryException(
    693▕                 $query, $this->prepareBindings($bindings), $e
    694▕             );
    695▕         }
    696▕     }

      +41 vendor frames 
  42  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Before proceeding to the next, I want to convey that I am currently using a Linux-based operating system Ubuntu.


Error could not find driver (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

I've fixed this error and I'm telling you about this. The trick is to install php-mysql. Open a terminal, you can use default terminal from Ubuntu/Linux or the terminal in Microsoft Visual Studio.

Use the following command:

sudo apt install php-mysql

Wait for the installation to complete. For example the following:

neon@pop-os:~$ sudo apt install php-mysql 
[sudo] password for neon: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  php7.4-mysql
The following NEW packages will be installed:
  php-mysql php7.4-mysql
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 123 kB of archives.
After this operation, 487 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu hirsute-security/main amd64 php7.4-mysql amd64 7.4.16-1ubuntu2.1 [121 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu hirsute/main amd64 php-mysql all 2:7.4+76ubuntu1 [2,008 B]
Fetched 123 kB in 2s (49.5 kB/s)      
Selecting previously unselected package php7.
4-mysql.
(Reading database ... 300820 files and direct
ories currently installed.)
Preparing to unpack .../php7.4-mysql_7.4.16-1
ubuntu2.1_amd64.deb ...
Unpacking php7.4-mysql (7.4.16-1ubuntu2.1) ..
.
Selecting previously unselected package php-m
ysql.
Preparing to unpack .../php-mysql_2%3a7.4+76u
buntu1_all.deb ...
Unpacking php-mysql (2:7.4+76ubuntu1) ...
Setting up php7.4-mysql (7.4.16-1ubuntu2.1) .
..

Creating config file /etc/php/7.4/mods-availa
ble/mysqlnd.ini with new version

Creating config file /etc/php/7.4/mods-availa
ble/mysqli.ini with new version

Creating config file /etc/php/7.4/mods-availa
ble/pdo_mysql.ini with new version
Setting up php-mysql (2:7.4+76ubuntu1) ...
Processing triggers for php7.4-cli (7.4.16-1u
buntu2.1) ...

After that, please do the migration command again in the terminal. For example I'm re-migrating using terminal:

> php artisan migrate
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (85.46ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (73.72ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (78.33ms)
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated:  2019_12_14_000001_create_personal_access_tokens_table (207.28ms)
Now Laravel has been able to migrate. Hope it is useful.
Next Post Previous Post
No Comment
Add Comment
comment url