Raldian
Raldian

Reputation: 18

Symfony Doctrine reset database

I'm trying to connect my symfony database with Sequel Pro (Database manegement tool) but the way Symfony set up doctrine when I first installed it was with "sqlite:///%kernel.project_dir%/var/data.db" and I cannot change this to mysql and set a custom password and user.

Is there any way to reset doctrine so I can start from scratch and set up the database with my own password and user?

I have tried doctrine:database:dump but this has not helped nor has it helped to remove doctrine and install it again.

Upvotes: 0

Views: 1970

Answers (1)

dlondero
dlondero

Reputation: 2597

Considering you're using Symfony 4 you need to update your .env file in order to use MySQL. Search for:

DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"

and replace it with:

DATABASE_URL="mysql://db_user:[email protected]:3306/db_name"

of course you need to customise it with user/password and database name you want to use.

Then in config/packages/doctrine.yaml make sure to have something like:

doctrine:
    dbal:
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4
        url: '%env(resolve:DATABASE_URL)%'

here make sure to set the right MySQL server version you're using.

Upvotes: 1

Related Questions