Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

etrainerspy's avatar

Errors occurred when using 'php artisan migrate'

I am learning from watching the video titled 'Laravel 5.4 From Scratch: Database Setup and Sequel Pro'.

When I type on the command line: php artisan migrate

I get the following error messages:

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

[PDOException] could not find driver ========================================

What does this mean? I am using PHP 7.1 with MariaDB.

0 likes
25 replies
rootchips's avatar

Be sure to configure the 'default' key in app/config/database.php.

etrainerspy's avatar

Ok, I just modified the database.php. I did the following:

======================================= 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'projLearn'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ], =======================================

I just changed the database name to 'projLearn' and username to 'root'. However, I am getting the same error message. Should I change the driver name? If so, to what?

cviv's avatar

You can also edit your .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=projLearn
DB_USERNAME=root
DB_PASSWORD=null

Make sure you already created your database

etrainerspy's avatar

I already changed the .env file as specified by the video. So, I am still stuck.

hendranucleo's avatar

Post your migrations code, please and you have pdo_mysql installed in your system ?

etrainerspy's avatar

How do I get my migrations code? I am not familiar with this.

I checked my modules. It shows that PDO is already installed.

MWDeveloper's avatar

@etrainerspy please try to delete your database tables manually from sequel_pro and run php artisan migrate one more time

etrainerspy's avatar

Sorry, I do not know sequel_pro. Isn't that a tool only for the mac. I am using Linux Mint 17?

etrainerspy's avatar

Ok, I deleted the 'projLearn' database. Is there a certain way to created this database with the table_name 'migrations'?

Cronix's avatar

are you able to connect to mysql using those settings manually? Like from the command prompt rather than laravel? "mysql -u root" then "use projLearn"?

etrainerspy's avatar

So, how do I get rid of the errors that are occurring when I run the 'php artisan migrate'?

etrainerspy's avatar

I was able to find the migrations code.

For the 2014_1012000000_create_users_table.php file the code is:

=======================================

Dracip's avatar

Are use sure you are using the same php version on Web Server and console? Check your Modules with "php -m" on console.

etrainerspy's avatar

I am using my computer as the Web Server.

When I run "php -m", I get the following: [PHP Modules] calendar Core ctype date dom exif fileinfo filter ftp gettext hash iconv json libxml mbstring openssl pcntl pcre PDO Phar posix readline Reflection session shmop SimpleXML sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zip zlib

[Zend Modules] Zend OPcache

etrainerspy's avatar

I guess there is no solution to this. It seems that no one knows here. I guess Laravel is too new for most users.

hendranucleo's avatar

Install or enable pdo_mysql extension. Here is my php extensions, pay attention to sql related.

PHP Module

1 like
etrainerspy's avatar

When I do 'php -m', it shows PDO listed. Is there a simple test for me to prove pdo is working?

hendranucleo's avatar

Do you really have pdo_mysql, not only PDO?, i have both. Create *.php file for test, and write:

<?php

var_dump(class_exists('PDO'));

// Or
var_dump(defined(PDO::MYSQL_ATTR_LOCAL_INFILE)); // mysql

// Or
var_dump(extension_loaded ('PDO' )); // returns boolean

// Or
var_dump(extension_loaded('pdo_mysql'));

// Or get all extensions and search for a specific one
var_dump(get_loaded_extensions()); 

and what you got?

2 likes
etrainerspy's avatar

Wow. Thanks, hendranucleo. That was it; pdo_mysql needed to be installed. .... much appreciated. :-)

jasrys's avatar

This is what I've found helpful in a dev environment (don't do this in production as you will lose all production data):

mysql -urootto open the mysql/mariadb console on your local machine (again, not your production machine). If you've changed your .env to use different db credentials, use them instead.

Now that you're in the mysql/mariadb console, run drop database projLearn (or whatever your database name is). This will delete it and allow you to start fresh.

Next, create a brand new database with create database projLearn. If you added new credentials to your .env file specifying a different database, use that database name instead.

Now you have an empty database ready for use.

If you have database migrations (like your create_users_table migration), you can now migrate them with php artisan migrate. This will set up the tables and columns specified in that file in your database.

Sometimes complex migrations or "half-way-through migration failures" mean this "dropping and re-adding the database" is one of the quickest and easiest ways to get back to ground zero so to speak in my experience.

hendranucleo's avatar

Do you solve your problem already? if yes close this question by accepting one answer as your best answer so people don't keep adding new answer to this question & will be guide for another people if they had similar problem.

Or if not, i bet you may try this:

  • Open your php installation folder, find php.ini and under extension un-comment pdo_mysql extension by removing ; from it. Path to php.ini ? use phpinfo(); and find loaded php ini info.
  • Restart your web server & test your PDO again.
1 like
amorphia's avatar

Hey hey,

I am having the same problem as the original poster, but unfortunately I didn't have the same fix.

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

[PDOException] could not find driver

I do apparently have both the PDO and pdo_mysql extensions installed and when I tried to run the tests hendranucleo suggested what failed was the second test, defined(PDO::MYSQL_ATTR_LOCAL_INFILE), here are my full results:

bool(true) bool(false) bool(true) bool(true) array(42) { [0]=> string(4) "Core" [1]=> string(6) "bcmath" [2]=> string(8) "calendar" [3]=> string(5) "ctype" [4]=> string(4) "date" [5]=> string(6) "filter" [6]=> string(4) "hash" [7]=> string(5) "iconv" [8]=> string(4) "json" [9]=> string(6) "mcrypt" [10]=> string(3) "SPL" [11]=> string(4) "pcre" [12]=> string(8) "readline" [13]=> string(10) "Reflection" [14]=> string(7) "session" [15]=> string(8) "standard" [16]=> string(7) "mysqlnd" [17]=> string(9) "tokenizer" [18]=> string(3) "zip" [19]=> string(4) "zlib" [20]=> string(6) "libxml" [21]=> string(3) "dom" [22]=> string(3) "PDO" [23]=> string(3) "bz2" [24]=> string(9) "SimpleXML" [25]=> string(3) "xml" [26]=> string(4) "wddx" [27]=> string(9) "xmlreader" [28]=> string(9) "xmlwriter" [29]=> string(14) "apache2handler" [30]=> string(7) "openssl" [31]=> string(4) "curl" [32]=> string(8) "fileinfo" [33]=> string(2) "gd" [34]=> string(7) "gettext" [35]=> string(8) "mbstring" [36]=> string(4) "exif" [37]=> string(6) "mysqli" [38]=> string(9) "pdo_mysql" [39]=> string(10) "pdo_sqlite" [40]=> string(4) "Phar" [41]=> string(3) "ftp" }

Any suggestions?

insight's avatar

Dear Friends,

I got the solution by

sudo apt-get install php-pgsql

Apache also needs to be restarted before sites can use it:

sudo systemctl restart apache2

Thanks

Anes

Please or to participate in this conversation.