2017-05-08 205 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