Skip to content

Documentation.need to be updated in the part of connection to database specially for my sql as below #18297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mina20088 opened this issue May 9, 2023 · 9 comments

Comments

@mina20088
Copy link

#The Connection Query string must contains the exact mysql version as an example if you have mysql version 8.0.32 # DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=8.0.32" #if you didn`t do that symfony will not create the database for you and you will not have any access

@mina20088 mina20088 linked a pull request May 9, 2023 that will close this issue
@javiereguiluz
Copy link
Member

Hi @mina20088. I don't use MySQL ... but for PostgreSQL I just use e.g. serverVersion=13 in the connection string and everything works as expected.

Could you please take a look to see if this is specific for MySQL or if maybe something in your app has something to do with this? Thanks!

@wouterj
Copy link
Member

wouterj commented May 9, 2023

As far as I know, the serverVersion is not required. If it's not set by a setting, Doctrine will connect to the database in order to figure out the server version. However, as this means it is connecting to the database more often (e.g. during cache warmup, as it needs to know the version to generate the cache), it is recommended to provide a server version.

@javiereguiluz
Copy link
Member

yes ... but it's enough to say "version = 13", "version = 8" or do you need to say "version = 13.4.1", "version = 8.0.32", etc.? At least for PostgreSQL is not needed ... but I don't know about MySQL.

@wouterj
Copy link
Member

wouterj commented May 9, 2023

You should always be as precise as possible (also with PostgreSQL), as this will make Doctrine choose the best platform as possible (sometimes, a patch version introduces a small BC break that requires Doctrine to slightly change its tooling).

https://github.com/doctrine/dbal/blob/3.6.x/src/Driver/AbstractMySQLDriver.php#L34-L78
https://github.com/doctrine/dbal/blob/3.6.x/src/Driver/AbstractPostgreSQLDriver.php#L29-L55

@mina20088
Copy link
Author

MySQL should be precises in defining the version

@mina20088
Copy link
Author

I have tried it but it never works untill I defined the version that why I made a pull request to update this section

@mina20088
Copy link
Author

@javiereguiluz hi I will make a new application and try this setup again and give a feed back but unfortunately I don't use other drivers like postgres oe SQLite but this issue is happing on the MySQL

@wouterj
Copy link
Member

wouterj commented May 15, 2023

I cannot reproduce this issue. When I start a new demo application, spin up a MySQL database and configure the env var without server version, it correctly creates the database:


Symfony Container Environment Variables
=======================================

 ------------------- ------------------ --------------------------------------------------------------------------
  Name                Default value      Real value
 ------------------- ------------------ --------------------------------------------------------------------------
  APP_SECRET          n/a                "***"
  DATABASE_URL        n/a                "mysql://root:[email protected]:32771/root?sslmode=disable&charset=utf8mb4"
  VAR_DUMPER_SERVER   "127.0.0.1:9912"   n/a
 ------------------- ------------------ --------------------------------------------------------------------------

 // Note real values might be different between web and CLI.

> symfony console doctrine:database:create
Created database `root` for connection named default

Please use one of the support channels (https://symfony.com/support) if you need more help getting this working.

@wouterj wouterj closed this as completed May 15, 2023
@wouterj wouterj closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
@mina20088
Copy link
Author

I created a new one and th same issue is there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants