Reputation: 631
I'm trying to connect with my DB (mysql) which is running on a server (docker). I'm programming on Windows.
In my symfony project I have done the following: parameters.yml
-> filled in the correct parameters
config.yml
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
php.ini
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
After all of this I get the following error: An exception occured in driver: could not find driver
Anyone who can help since I have tried some solutions that were provided but none worked or were for linux systems.
Upvotes: 16
Views: 70721
Reputation: 96
I was having this problem on my docker environment using the php:8.1-fpm-alpine
image and Symfony 6. I fixed it by adding the following line to my Dockerfile:
RUN docker-php-ext-install pdo_mysql
Upvotes: 4
Reputation: 33
comment this line in your .env
file. yourproject/.env
#DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"file
and delete #
in first of your mysql config code
set your username and password in this part
DATABASE_URL="mysql://usename:[email protected]:3306/test?serverVersion=5.7"
Upvotes: 3
Reputation: 673
In my case it was a missing i
at the end of mysql
as found on a tutorial online, since on my PC I have the mysqli
PHP's extension enabled instead of mysql
, which is long deprecated by now.
So I edited the Symfony's .env.local
DATABASE_URL
entry this way:
DATABASE_URL="mysqli://youruser:[email protected]:3306/yourdbname"
Just mind the first part with mysqli
, other data is dependent on your setup.
Upvotes: 3
Reputation: 354
In case this helps others: I've encountered the same problem, when running a command that needed the database (such as bin/console make:migration
), but for a totally different reason. I was running the command from my computer instead of running it inside the php container. Running it inside the php container solved the problem.
Upvotes: 3
Reputation: 631
Ok, I made a very stupid mistake. I was editing the php.ini file, but I didn't renamed it to php.ini (it was php.ini-prod). Afterwards I just had to put the correct path in extension_dir and it's working.
Hopefully this helps others.
Upvotes: 4