@lottie
To use MySQL instead of MariaDB in Symfony 5, you need to modify the database configuration settings. Here are the steps to follow:
- Open the .env file and modify the DATABASE_URL parameter to use the MySQL connection string. It should look like this:
1
|
DATABASE_URL=mysql://your_username:your_password@your_host:your_port/your_database_name
|
Replace your_username
, your_password
, your_host
, your_port
, and your_database_name
with your actual MySQL connection details.
- Update your config/packages/doctrine.yaml file to use the MySQL driver instead of the default MariaDB driver. Replace the server_version and charset values as well. Here is an example:
1
2
3
4
5
|
doctrine:
dbal:
driver: 'pdo_mysql'
server_version: '8.0'
charset: utf8mb4
|
- Clear the Symfony cache by running the following command in your terminal:
1
|
php bin/console cache:clear
|
- Generate the migration files if you have any by running:
1
|
php bin/console doctrine:migrations:diff
|
- Apply the migration to your MySQL database by running:
1
|
php bin/console doctrine:migrations:migrate
|
That's it! Symfony 5 should now be using MySQL instead of MariaDB as the database engine.