Error Laravel Artisan Migrate Could Not Find Driver

Illumniate Database QueryException

Laravel Artisan Migrate Error Could Not Find Driver  IlluminateDatabaseQueryException –  Salah satu fitur unggulan dari Laravel adalah dengan adanya sebuah tool yang disebut dengan Artisan. Dengan Artisan salah satu kemampuannya adalah membuat database melalui terminal.

Cara Atasi Error Laravel Artisan Migrate Could Not Find Driver


Saat dibuat saya mengalami error saat ingin membuat migrasi database. Adapun error yang saya alami adalah sebagai berikut:

 Illuminate\Database\QueryException

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

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:795
    791▕         // If an exception occurs when attempting to run a query, we'll format the error
    792▕         // message to include the bindings with SQL, which will make this exception a
    793▕         // lot more helpful to the developer instead of just the database's errors.
    794▕         catch (Exception $e) {
  ➜ 795▕             throw new QueryException(
    796▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    797▕             );
    798▕         }
    799▕     }

      +35 vendor frames

  36  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Sebelum lanjut ke pembahasan selanjutnya, saya ingin menyampaikan bahwa saya saat menggunakan sistem operasi linux berbasis Ubuntu.



Cara Perbaiki Cara memperbaiki Error could not find driver (SQL: SHOW FULL TABLES WHERE table_type = ‘BASE TABLE’)

Saya telah memperbaiki error dan saya sampaikan kepada kalian. Caranya adalah dengan melakukan instalasi php-mysql. Buka terminal di linux anda, baik terminal bawaan dari Ubuntu/Linux maupun terminal yang ada didalam Microsoft Visual Studio.

Gunakan perintah berikut:

sudo apt install php-mysql

Tunggu instalasi hingga selesai. Sebagai contoh berikut :

neon@X407:~$ sudo apt install php-mysql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cura-engine fdm-materials libarcus3 libgeos-c1v5 libgeos3.10.2
  libnlopt0 libpolyclipping22 libqt5qmlworkerscript5
  libqt5quickcontrols2-5 libqt5quicktemplates2-5
  libqt5quickwidgets5 libsavitar0 python3-arcus python3-certifi
  python3-charon python3-idna python3-ifaddr python3-pynest2d
  python3-pyqt5.qtopengl python3-pyqt5.qtquick python3-pyqt5.qtsvg
  python3-python-utils python3-requests python3-savitar
  python3-sentry-sdk python3-shapely python3-stl python3-uranium
  python3-urllib3 python3-zeroconf
  qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings
  qml-module-qtgraphicaleffects qml-module-qtqml
  qml-module-qtqml-models2 qml-module-qtquick-controls
  qml-module-qtquick-controls2 qml-module-qtquick-dialogs
  qml-module-qtquick-layouts qml-module-qtquick-privatewidgets
  qml-module-qtquick-templates2 qml-module-qtquick-window2
  qml-module-qtquick2 uranium-plugins
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  php8.1-mysql
The following NEW packages will be installed:
  php-mysql php8.1-mysql
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 132 kB of archives.
After this operation, 476 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://security.ubuntu.com/ubuntu jammy-security/main amd64 php8.1-mysql amd64 8.1.2-1ubuntu2.13 [130 kB]
Get:2 http://mirrors.ubuntu.com/mirrors.txt Mirrorlist [1,018 B]
Get:3 http://kebo.pens.ac.id/ubuntu jammy/main amd64 php-mysql all 2:8.1+92ubuntu1 [1,834 B]
Fetched 133 kB in 2s (81.1 kB/s)
Selecting previously unselected package php8.1-mysql.
(Reading database ... 180602 files and directories currently installe
d.)
Preparing to unpack .../php8.1-mysql_8.1.2-1ubuntu2.13_amd64.deb ...
Unpacking php8.1-mysql (8.1.2-1ubuntu2.13) ...
Selecting previously unselected package php-mysql.
Preparing to unpack .../php-mysql_2%3a8.1+92ubuntu1_all.deb ...
Unpacking php-mysql (2:8.1+92ubuntu1) ...
Setting up php8.1-mysql (8.1.2-1ubuntu2.13) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall an
d 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/8.1/mods-available/mysqlnd.ini with new
 version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall an
d 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/8.1/mods-available/mysqli.ini with new
version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall an
d 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/8.1/mods-available/pdo_mysql.ini with n
ew version
Setting up php-mysql (2:8.1+92ubuntu1) ...
Processing triggers for php8.1-cli (8.1.2-1ubuntu2.13) ...

Setelah itu, silahkan anda lakukan perintah migrasi kembali pada terminal. Sebagai contoh saya melakukan migrasi sebagai berikut:

> 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)

Kini laravel seharusnya telah bisa melakukan migrasi. Semoga artikel ini bermanfaat.

Baca juga:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top