Symfony3 - SQLSTATE[HY000] [2002] No such file or directory

后端 未结 8 1518
夕颜
夕颜 2020-12-19 16:26

I am new to Symfony and started doing some tutorials in order to get some things done. I am working on a Linux Mint 18 machine and a standard Symfony3-project.

I\'d

8条回答
  •  温柔的废话
    2020-12-19 17:04

    May be It's too late but I had the same issue "SQLSTATE[HY000] [2002] No such file or directory" on my symfony 3.2.9 deployment

    I fixed it by changing the database_host value from "localhost" to my server IP on my parameters.yml file

    but I had this another error message when trying to run commandline by SSH:

    [Doctrine\DBAL\Exception\ConnectionException]
     An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused
    

    I finaly fix it by adding these 2 lines on my config.yml file in Doctrine configuration section :

    unix_socket: /var/lib/mysql/mysql.sock
    server_version: '5.5'
    

    all my final doctrine configuration is like this:

    doctrine:
        dbal:
            driver: pdo_mysql
            host: '%database_host%'
            port: '%database_port%'
            dbname: '%database_name%'
            user: '%database_user%'
            password: '%database_password%'
            unix_socket: /var/lib/mysql/mysql.sock
            server_version: '5.5'
            charset: UTF8
    

    hopefully this helps someone

提交回复
热议问题