简体   繁体   English

我的PHP应用程序是否可以与Heroku的ClearDB MySql资源一起使用?

[英]Will my PHP application work with Heroku's ClearDB MySql resource?

I am new to both php and Heroku and I have run into a bit of a problem. 我是php和Heroku的新手,我遇到了一些问题。 Currently my application is running fine on my xxamp testing server with mysql however when I try to host it on Heroku, there is no connection to the MySql server. 目前我的应用程序在我的xxamp测试服务器上使用mysql正常运行但是当我尝试在Heroku上托管它时,没有与MySql服务器的连接。

    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)' in /app/www/pdo_testdb_connect.php:6 Stack trace: #0 /app/www/pdo_testdb_connect.php(6): PDO->__construct('mysql:host=127....', 'd2398h23d9d82j3', '8dj1292d3') #1 /app/www/all.php(6): testdb_connect() #2 {main} thrown in /app/www/pdo_testdb_connect.php on line 6 

Does ClearDB not work with PHP? ClearDB不能与PHP一起使用吗? Any suggestions would be much appreciated as I've sort of hit a brick wall. 任何建议都会非常感激,因为我有点像砖墙。

Here is the php integration of Cleardb with Heroku: 这是Cleardb与Heroku的php集成:

define ('DB_USER','xxxxxxxxxxxxxxxx');
define ('DB_PASSWORD','yyyyyyyyyyyyyy');
define ('DB_HOST','us-cdbr-east.cleardb.com');
define ('DB_NAME','heroku_zzzzzzzzzzzzzzzzzz');

Take the params by going in Git and typing heroku config. 通过进入Git并键入heroku配置来获取参数。 You will see a CLEARDB_DATABASE_URL 您将看到CLEARDB_DATABASE_URL

Here is how to decode it: 以下是解码方法:

mysql://xxxxxxxxxxxxxx:yyyyyyyy@us-mm-auto-dca-01.cleardb.com/heroku_zzzzzzzzzzzzzzz

Interestingly enough, in the official documentation they provide only a Ruby example but nothing about php.. http://devcenter.heroku.com/articles/cleardb 有趣的是,在官方文档中,他们只提供了一个Ruby示例,但没有关于php的内容.http: //devcenter.heroku.com/articles/cleardb

heroku config | grep CLEARDB_DATABASE_URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM