1

I am trying to create a table in my mysql using doctrine. (I am learning symfony using this video in French: https://www.youtube.com/watch?v=UTusmVpwJXo , it seems that the video is based on a previous version of synfony but hey, should be almost the same right).

So the command I am running is: php bin/console doctrine:database:create

Unfortunately I have these results:

errors errors2 doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        driver: 'pdo_mysql'
        url: '%env(resolve:DATABASE_URL)%'
        server_version: '7.4.4'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

and then my .env

# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=b3b1c82ba50949ebe4f89ac492c6c7f6
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###

###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
###< symfony/mailer ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL="mysql://root:@127.0.0.1:3306/blog"
###< doctrine/doctrine-bundle ###

I didn't set any password, and my phpmyadmin is running correctly at http://127.0.0.1:8080/phpmyadmin/

And my mysql conf looks like this: mysqlconf Maybe it changes anything (but I don't think so), my main page is running on http://127.0.0.1:8000/blog and runs good. I started the server with symfony server:start -d.

Do you guys know what I could have done wrong here?

Thank you for any future help!! Stay strong in this hard times and learn more!

Oleg G.
  • 550
  • 5
  • 25
  • Can you connect from the command line, ie `mysql --user root --host 127.0.0.1 --port 3306 blog` – Phil Apr 20 '20 at 06:45
  • interesting, I just installed mysql (brew install mysql-client) and when using `mysql -v` i have this error `➜ ~ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)` – Oleg G. Apr 20 '20 at 07:11
  • I installed `mysql` instead, i now have this error `ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: NO) ` – Oleg G. Apr 20 '20 at 07:23
  • Alright, I succeeded to make sql work in my terminal. If i remove blog from your shell command, it works. but connect to the wrong mysql since it is empty. I want to connect to the one from my Xampp server. When I run it on 8080 it says `ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0`, it I run it on 3306, it succeed to connect but to the one from symfony i guess because when I show databases; it doesn't show the test one that I have by going at this url ``http://127.0.0.1:8080/phpmyadmin/index.php` – Oleg G. Apr 20 '20 at 08:36
  • using xampp, my url is http://192.168.64.2/ now I still have `ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 3 ` – Oleg G. Apr 20 '20 at 09:05

1 Answers1

-1

I finally found my solution here -> Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

It was a default behavior of sql as a security process.

I follow the exact step described in the answer and it worked.

Oleg G.
  • 550
  • 5
  • 25