mac下pdo連結錯誤

來源:互聯網
上載者:User
mac 報如下錯誤:

[Sun Sep 06 23:44:10.162087 2015] [:error] [pid 1004] [client 127.0.0.1:52136] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Users/yuan/www/phpems/lib/pepdo.cls.php:23\nStack trace:\n#0 /Users/yuan/www/phpems/lib/pepdo.cls.php(23): PDO->__construct('mysql:host=loca...', 'root', 'db10056')\n#1 /Users/yuan/www/phpems/lib/pepdo.cls.php(90): pepdo->connect()\n#2 /Users/yuan/www/phpems/lib/session.cls.php(86): pepdo->fetch(Array)\n#3 /Users/yuan/www/phpems/lib/session.cls.php(31): session->getSessionValue('443cd730d32899e...')\n#4 /Users/yuan/www/phpems/lib/session.cls.php(17): session->getSessionId()\n#5 /Users/yuan/www/phpems/lib/init.cls.php(79): session->__construct(Object(ginkgo))\n#6 /Users/yuan/www/phpems/app/content/app.php(19): ginkgo->make('session')\n#7 /Users/yuan/www/phpems/lib/init.cls.php(133): app->__construct(Object(ginkgo))\n#8 /Users/yuan/www/phpems/index.php(7): ginkgo->run()\n#9 {main}\n thrown in /Users/yuan/www/phpems/lib/pepdo.cls.php on line 23

自己的解決方案如下:

1:拷貝一份php.ini檔案

cd /private/etc/

sudo cp php.ini.default php.ini

sudo vi php.ini

2: 修改php.ini中的所有的default_socket都改成/tmp/mysql.sock (我的mysql的sock在tmp中)。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.