Troubleshooting “No such file or directory” when running `php app/console doctrine:schema:create`

后端 未结 12 1248
臣服心动
臣服心动 2020-12-04 23:35

I am new to Symfony2 (beta4) and Doctrine and am having issues when i try to create the DB schema via command line.

Here\'s the error:

$ php app/cons         


        
相关标签:
12条回答
  • 2020-12-05 00:15

    Sometimes you may got several solution for location path of mysql.lock. But I think the best solution is just see the location path of mysql using php phpinfo() function.

    Note: if you are not familar with phpinfo(), then just create a file give any name and include content of that file like this

    <?php
    phpinfo();
    ?>
    

    run this file and get the path of mysql.lock file. I think it will help.

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

    The problem for me was the mysql.default_socket setting in PHP.INI defaults to a different location than where MySQL actually puts that file.

    Instead of editing the config files, I created an alias in the location that PHP is looking that connects to the real mysql.sock.

    Just run these two commands (no restart needed):

    mkdir /var/mysql
    ln -s /tmp/mysql.sock /var/mysql/mysql.sock
    
    0 讨论(0)
  • 2020-12-05 00:21

    Too late but I hope it can help someone.

    Just today I fall into a similar situation (but in other context, I was trying to create entities from db).

    I solved it simply modifying de database_host from "localhost" to "127.0.0.1" in the parameters.ini file.

    I think my Mysql instance is running only via TCP and not socket and because this when use database_host="localhost" it fails.

    0 讨论(0)
  • 2020-12-05 00:22

    I changed 'host'=> 'localhost' to 'host'=> '127.0.0.1' on app/config/database.php and everything is working correctly

    0 讨论(0)
  • 2020-12-05 00:24

    Had the same issue "SQLSTATE[HY000] [2002] No such file or directory" on symfony 3.2.9 on 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

    0 讨论(0)
  • 2020-12-05 00:26

    I think just restart the mysql, and apache, that's work for me.

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