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

后端 未结 8 1427
夕颜
夕颜 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 16:58

    You don't have MySQL installed, Install MySQL first

    0 讨论(0)
  • 2020-12-19 17:00

    if you use mamp test this:

    sudo ln -s /Applications/MAMP/tmp/mysql /var/mysql
    
    0 讨论(0)
  • 2020-12-19 17:01

    My knowledge of MySQL suggests one variant which might happen and explain this:

    You had (old) mysqld running, then deleted out all files from datadir. Then probably new server wasn't able to start up Then you connected to that old mysqld, which is still running, but getting 'No such file or directory' error trying to access own system files (which were deleted).

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-12-19 17:08

    [PDOException] SQLSTATE[HY000] [2002] No such file or directory

    This error occurs generally when your web application is not connected to the database. As per your parameter.yml it's searching for mysql server & wasn't getting connected because at that time mysql wasn't installed there at your machine.

    0 讨论(0)
  • 2020-12-19 17:10

    In my case, I only changed localhost->127.0.0.1 and it worked!

    0 讨论(0)
提交回复
热议问题