Here’s a list of stuff I’ve done in order to attempt to fix the issue:
I’m on Windows 7 and using MAMP. My PHP version is 7.3.7.
The full error I’m getting is:
IlluminateDatabaseQueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = lol and table_name = migrations and table_type = 'BASE TABLE')
at C:MAMPhtdocsLeague Of Legends BackendvendorlaravelframeworksrcIlluminateDatabaseConnection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 DoctrineDBALDriverPDOException::("could not find driver")
C:MAMPhtdocsLeague Of Legends BackendvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:31
2 PDOException::("could not find driver")
C:MAMPhtdocsLeague Of Legends BackendvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:27
Please use the argument -v to see more details.
Used phpinfo()
on one of the pages served by the server in order to determine PHP version and location of php.ini
file. My PHP version is 7.3.7 and my php.ini
file is located at C:MAMPconfphp7.3.7php.ini
. These 3 lines are uncommented in that file:
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
Used get_loaded_extensions on one of the pages served by the server in order to see all loaded extensions. This is the list:
array:45 [▼
0 => "Core"
1 => "bcmath"
2 => "calendar"
3 => "com_dotnet"
4 => "ctype"
5 => "date"
6 => "filter"
7 => "hash"
8 => "iconv"
9 => "json"
10 => "SPL"
11 => "odbc"
12 => "pcre"
13 => "Reflection"
14 => "session"
15 => "sockets"
16 => "standard"
17 => "mysqlnd"
18 => "tokenizer"
19 => "zip"
20 => "zlib"
21 => "libxml"
22 => "dom"
23 => "PDO"
24 => "bz2"
25 => "SimpleXML"
26 => "soap"
27 => "xml"
28 => "wddx"
29 => "xmlreader"
30 => "xmlwriter"
31 => "apache2handler"
32 => "openssl"
33 => "gd"
34 => "gettext"
35 => "mbstring"
36 => "exif"
37 => "mysqli"
38 => "pdo_sqlite"
39 => "sqlite3"
40 => "curl"
41 => "Phar"
42 => "imagick"
43 => "pdo_mysql"
44 => "fileinfo"
]
In Laravel’s database.php file, MySQL is set as default:
'default' => env('DB_CONNECTION', 'mysql'),
I tried using composer update and composer dump-autoload too.
My database env variables are set correctly. I can interact with my database by inserting, deleting, updating and selecting, however, I cannot migrate for some reason:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lol
DB_USERNAME=root
DB_PASSWORD=root
I’ve read through all similar questions here and I’m out of options now.
4
Answers
can you try adding a file called php.php under public folder with the content
and access it by the web URL not command line and make sure the mysql pdo extension enabled
It means that for command line probably other
php.ini
is used that you updated. That’s why when running site everything is working and when running PHP from console it doesn’t.You should run
in command line to see what configuration files are used and make sure you have enabled in there MySQL.
you need install driver mysql for php. example for ubuntu
sudo apt install php-mysql
You need to check if you have mysql pdo extension also check if DATABASE_TABLE exists which is running on your system otherwise you have to install it. that error is shown when you are trying to use database which is not on you machine.