2017-05-08 255 views
0

無法使用這些參數連接到數據庫,我上傳了我的本地項目在我的cPanel,但我沒有使它的工作。無法連接到數據庫Symfony 3

錯誤消息:

{ 「代碼」:500, 「消息」:「在驅動時發生異常:SQLSTATE [HY000] [2003]無法連接到MySQL服務器上「127.0。 0.1' (111)「}

日誌:

[2017-05-08 10:37:09] request.INFO: Matched route "get_users". {"route":"get_users","route_parameters":{"_controller":"SwipeBundle\\Controller\\Backend\\API\\UserController::getUsersAction","_format":"json","_route":"get_users"},"request_uri":"http://swipe.com.ph/api/users","method":"GET"} [] 
[2017-05-08 10:37:09] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":3} [] 
[2017-05-08 10:37:09] security.DEBUG: Calling getCredentials() on guard configurator. {"firewall_key":"main","authenticator":"SwipeBundle\\Security\\LoginFormAuthenticator"} [] 
[2017-05-08 10:37:09] security.DEBUG: Calling getCredentials() on guard configurator. {"firewall_key":"main","authenticator":"SwipeBundle\\Security\\AdminLoginFormAuthenticator"} [] 
[2017-05-08 10:37:09] security.DEBUG: Calling getCredentials() on guard configurator. {"firewall_key":"main","authenticator":"SwipeBundle\\Security\\AccountLoginFormAuthenticator"} [] 
[2017-05-08 10:37:09] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] 
[2017-05-08 10:37:09] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occured in driver: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)" at /home/swipecom/contactless/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 0): An exception occured in driver: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) at /home/swipecom/contactless/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\\DBAL\\Driver\\PDOException(code: 2003): SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) at /home/swipecom/contactless/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2003): SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) at /home/swipecom/contactless/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} [] 

Parameters.yml

parameters: 
    database_driver: pdo_mysql 
    database_host: 127.0.0.1 
    database_port: 3306 
    database_name: com_contactless 
    database_user: com_swipe 
    database_password: Js121716 
    mailer_transport: smtp 
    mailer_host: 127.0.0.1 
    mailer_user: null 
    mailer_password: null 
    secret: ThisTokenIsNotSoSecretChangeIt 

我在parametes.yml檢查的價值觀和我發誓,他們是正確的

+1

數據庫端口通常是3306 – Scriptable

+0

可能是主機不正確。許多託管服務在不同的機器上都有數據庫 – Volvox

+0

我更新我的代碼,請檢查。 – phpmeter

回答

1

標準MySQL端口是3306,除非你已經被你的供應商使用該另一端口告訴,你應該堅持默認。

嘗試手動連接通過終端:通過添加-h-h127.0.0.1

如果

mysql -uswipecom_swipe -p localhost 

,如果你確實是一個不同的端口上運行添加-P8889的命令,你也可以選擇一臺主機仍然不起作用,請確保密碼正確並檢查用戶是否可以從本地主機訪問。

+0

我在cpanel中運行應用程序。我沒有終端來檢查它。 – phpmeter

+0

在cpanel,轉到Mysql數據庫並檢查數據庫名稱,用戶和訪問 – Scriptable

+0

我檢查了數據庫名稱,甚至是用戶名和密碼,但仍然無法連接? – phpmeter