How to use mysql instead of mariadb in symfony 5

i think this might be a stupid question for some, but i swear that i can’t find the answer by myself actually.

I’m still learning Symfony so please be nice.

Actually i have set up the access to my database in the .env file :

[...]
DATABASE_URL=mysql://root:[email protected]:3308/db_name
[...]

And then i have define the environnement variable in the config/doctrine.yaml :

doctrine:
    dbal:
      default_connection: default
      connections:
        default:
          dbname:           Symfony
          user:             root
          password:         null
          host:             localhost
          server_version:   '8.0'
          driver: pdo_mysql
          charset: UTF8

So i run the following command :

> php bin/console doctrine:database:create

But the ‘Symfony’ database have been created under mariadb.

🙁 I don’t understand why because i have define precisely that i use a 8.0 version and this version is not a mariadb version.

I’ve also try this :

# .symfony/services.yaml
mydatabase:
    # supported versions: 5.7, 8.0
    type: oracle-mysql:8.0
    disk: 1024

As the symfony documentation saying to do, but it still not working at all.
I have got the following error message as mydatabase is not a symfony services :

C:UsersvincpSymfonycharming_tuto>php bin/console doctrine:database:create

In FileLoader.php line 173:

  There is no extension able to load the configuration for "mydatabase" (in "C:UsersvincpSymfonycharming_tutocon
  fig/services.yaml"). Looked for namespace "mydatabase", found ""framework", "sensio_framework_extra", "twig", "twig
  _extra", "web_profiler", "monolog", "debug", "webpack_encore", "doctrine", "doctrine_migrations", "maker"" in C:Us
  ersvincpSymfonycharming_tutoconfig/services.yaml (which is being imported from "C:UsersvincpSymfonycharming
  _tutosrcKernel.php").

I wanna use mysql because this is the DBMS that i use usually.
(If you think that i should use mariadb instead of mysql i’m open to that, but give me some arguments. I’d be really interseted in)

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *