Thursday, August 8, 2019

PHP: connect to mysql

首先要確保以下幾點︰
1. apache有沒有允許連接到接口,可以查看host設置->Directory->Allow from all
2. 數據庫的用戶有沒有權限在第二個host登入,如果沒有權限可能會出︰
Caught exception: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 0
如果真的有這個錯誤,請到用戶權限新增在這個host。
可參考這裏︰https://manage.accuwebhosting.com/knowledgebase/2200/How-to-Allow-Remote-Connection-to-MySQL-Server-in-Windows.html

No comments: