我试图部署一个PHP应用程序使用附加cleardb / MySQL没有成功。
我所做的是:
git init git add . git commit -m "First commit" heroku create --stack cedar git push heroku master heroku addons:add cleardb:ignite heroku config | grep CLEARDB_DATABASE_URL heroku config:add DATABASE_URL='mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true'
之后,我configuration我的PHP应用程序使用:
<?php $url=parse_url(getenv("mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true")); $server = $url["host"]; $username = $url["user"]; $password = $url["pass"]; $db = substr($url["path"],1); mysql_connect($server, $username, $password); mysql_select_db($db); ?>
而当我testing连接,我收到错误:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
我能做什么? 请帮忙吗?
谢谢。
编辑:
好吧,我已经解决了我自己的问题设置服务器configuration手动:
$server = "us-cdbr-east.cleardb.com"; $username = "adffdadf2341"; $password = "adf4234"; $db = "heroku_db";
现在我有新的问题,heroku db:推不工作
! Taps Load Error: cannot load such file -- taps/operation ! You may need to install or update the taps gem to use db commands. ! On most systems this will be: ! ! sudo gem install taps
我已经安装了gem,仍然是相同的错误…
你不这样做
$url=parse_url(getenv("mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true"))
getenv =在你的unix上获得一个环境。
所以
$url=parse_url(getenv(CLEARDB_DATABASE_URL))
很好。