Db mysql e symfony

di il
4 risposte

Db mysql e symfony

Ciao a tutti,

Rieccomi con un altro problema da risolvere che ovviamente non so come fare, e sono qui a chiedere aiuto a voi che sicuramente ne sapete di più di me.

Dunque sto connettendo un database con un progetto symfony con doctrine

al comando: php bin/console doctrine:database:create

ricevo questa risposta da terminale:

In AbstractPostgreSQLDriver.php line 88:

An exception occurred in driver: SQLSTATE[08006] [7] could not connect to s
erver: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?


In Exception.php line 18:

SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?


In PDOConnection.php line 39:

SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?


doctrine:database:create [-s|--shard SHARD] [-c|--connection [CONNECTION]] [--if-not-exists]

mi sembra di ricordare che bisogna deflagrare qualcosa nel file php.ini se non ricordo male


qualcuno sa come risolvere ? grazie mille a chiunque risponda

4 Risposte

  • Re: Db mysql e symfony

    Gr3cale069 ha scritto:


    An exception occurred in driver: SQLSTATE[08006] [7] could not connect to s
    erver: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?
    Scusa, ma come DB stai usando mysql/mariadb o postgresql? Mysql non usa la porta 5432

    Le possibili connessioni sono queste
    DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
    mariadb:
    DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=mariadb-10.5.8"
    qlite:
    DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
    ostgresql:
    DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
    oracle:
    DATABASE_URL="oci8://db_user:db_password@127.0.0.1:1521/db_name"


  • Re: Db mysql e symfony

    Ciao Tatino, grazie per avere risposto.

    Come db sto usanda mysql. Ho configurato il file .env in questo modo:

    ###> doctrine/doctrine-bundle ###
    # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
    # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
    #
    # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
    DATABASE_URL="mysql://nome utente db:password db@127.0.0.1:5432/nomedb?serverVersion=5.7"
    # DATABASE_URL="postgresql://root:@password/nomedb?serverVersion=13&charset=utf8"
    ###< doctrine/doctrine-bundle ###

    ho cambiato la porta come da te suggerito, e mi da questo errore:

    In AbstractMySQLDriver.php line 112:

    An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused


    In Exception.php line 18:

    SQLSTATE[HY000] [2002] Connection refused


    In PDOConnection.php line 39:

    SQLSTATE[HY000] [2002] Connection refused


    doctrine:database:create [-s|--shard SHARD] [-c|--connection [CONNECTION]] [--if-not-exists]
  • Re: Db mysql e symfony

    Ciao Tatino, grazie per avere risposto.

    Come db sto usanda mysql. Ho configurato il file .env in questo modo:

    ###> doctrine/doctrine-bundle ###
    # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
    # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
    #
    # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
    DATABASE_URL="mysql://nome utente db:password db@127.0.0.1:5432/nomedb?serverVersion=5.7"
    # DATABASE_URL="postgresql://root:@password/nomedb?serverVersion=13&charset=utf8"
    ###< doctrine/doctrine-bundle ###

    ho cambiato la porta come da te suggerito, e mi da questo errore:

    In AbstractMySQLDriver.php line 112:

    An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused


    In Exception.php line 18:

    SQLSTATE[HY000] [2002] Connection refused


    In PDOConnection.php line 39:

    SQLSTATE[HY000] [2002] Connection refused


    doctrine:database:create [-s|--shard SHARD] [-c|--connection [CONNECTION]] [--if-not-exists]
  • Re: Db mysql e symfony

    Gr3cale069 ha scritto:


    DATABASE_URL="mysql://nome utente db:password db@127.0.0.1:5432/nomedb?serverVersion=5.7"
    Non hai cambiato la porta, devi mettere quella utilizzata da mysql
    DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
Devi accedere o registrarti per scrivere nel forum
4 risposte