Can't create database with Symfony 4.1 : could not find driver
18,282
Solution 1
RiggsFolly brought the solution :
I have a second php.ini
file in UwAmp. The extension pdo_mysql
was disabled in bin/php/php-version/php.ini
Solution 2
This works for my case
symfony 4.2
php 7.3
I enabled
extension=pdo_mysql
in php.ini
Solution 3
in file=> config\packages\doctrine.yaml
dbal:
dbname: database
host: localhost
port: 1234
user: user
password: secret
driver: pdo_mysql
# if the url option is specified, it will override the above config
url: mysql://db_user:[email protected]:3306/db_name
# the DBAL driverClass option
driver_class: App\DBAL\MyDatabaseDriver
Related videos on Youtube
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
When i do the command php bin/console doctrine:database:create i have these errors :
In AbstractMySQLDriver.php line 126: An exception occurred in driver: could not find driver
In PDOConnection.php line 50: could not find driver
In PDOConnection.php line 46: could not find driver
config/packages/doctrine.yaml
doctrine: dbal: # configure these for your database server driver: 'pdo_mysql' server_version: '5.7' charset: utf8mb4 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci
.env
DATABASE_URL=mysql://root:[email protected]:3306/blogMyProject
My PHP Extensions:
php.ini extensions:
PHP 7.2.7 - MySQL 5.7.11 - Symfony 4.1.4 - I use UwAmp 3.1.0 - I'm on Windows
I don't understand where these errors come from.
-
RiggsFolly over 5 yearsDo you have a seperate
php.ini
for the PHP CLI in UwAmp if so check that all the required extensions are activated in there as well as thephp.ini
used by your web server -
Preciel over 5 yearsCheck if
php-mysql
is installed on your server -
Admin over 5 years@RiggsFolly i have add my php.ini on my post. I have the extension pdo_mysql.
-
Admin over 5 years@Preciel i use UwAmp on Windows, not Linux.
-
RiggsFolly over 5 yearsRight: But as I said in my previous comment. Some systems have 2
php.ini
files. One is used by the PHP under Apache and the other is used by PHP CLI (Command Line Interface) Look in the folder containingPHP
and see if there is aphp.ini
in that folder. That will be the one used by the CLI -
Admin over 5 yearsSorry, I misunderstand.It works ! It was necessary to modify the php.ini of the bin / php directory, thank you :)
-
-
Syscall about 3 yearsThank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you’ve made.
-
José Ricardo Júnior over 2 yearsActually, all you need is the driver and url parameters, as the url already contains user, password, host and port.