CakePHP: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

后端 未结 3 942
甜味超标
甜味超标 2020-12-30 06:41

I have had a cakephp app running fine on my local machine (mac osx) for a while and then suddently I realise that I can\'t connect to mysql.sock.

I\'m getting this

相关标签:
3条回答
  • 2020-12-30 07:16

    If you are having problem with CakePHP 2.0, try this:

    sudo mkdir /var/mysql
    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
    
    0 讨论(0)
  • 2020-12-30 07:22

    Try passing an absolute path the the mysql.sock file in the APP/config/database.php

    <?php
        class DATABASE_CONFIG {
            var $default = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'dbUser',
                'password' => 'dbPassword',
                'database' => 'dbName',
                'prefix' => '',
                'port' => '/path/to/mysql.sock'
            );
        }
    

    This is better than running via an ip for local connection as the socket connection is much, much faster.

    0 讨论(0)
  • 2020-12-30 07:23

    In phpcake 2.0 use 'unix_socket' instead of port

    <?php
        class DATABASE_CONFIG {
            var $default = array(
                'datasource' => 'Database/Mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'dbUser',
                'password' => 'dbPassword',
                'database' => 'dbName',
                'prefix' => '',
                'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock', //Path for mac XAMPP
            );
        }
    
    0 讨论(0)
提交回复
热议问题