Heroku 与 mysql ?
我使用 php 编写了一个应用程序,但在 facebook 和安全 (SSL) 出现几个问题后,我将其从我的免费网络主机移至 Heroku。
然而,在这样做之后,我在使用我的旧 MySQL 数据库(仍然位于我的旧网络主机中)时遇到了一些麻烦。
我尝试使用以下代码连接到数据库:
$hostname_fb2 = "mysqldb.000webhost.com";
$database_fb2 = "my_db";
$username_fb2 = "my_user_name";
$password_fb2 = "my_pass";
$fb2 = mysql_pconnect($hostname_fb2, $username_fb2, $password_fb2) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_fb2, $fb2);
$result = mysql_query("select * from users where id='". $my_id ."';",$fb2);
生成此错误消息(在白屏上等待一段时间后):
警告:mysql_pconnect():在“读取初始通信数据包”时丢失与 MySQL 服务器的连接,系统错误:/app/www/fb2.php 第 9 行中的 110 致命错误:在“读取初始通信数据包”时丢失与 MySQL 服务器的连接通信包',系统错误:110 in /app/www/fb2.php on line 9
那么...有没有办法通过 Heroku 连接 000webhost 的 MySQL 服务器?
I've writted an app using php, but after several issues with facebook and security (SSL) I moved it from my free webhost to Heroku.
However, after doing that, I'm facing some troubles using my good old MySQL database (still sitting in my old webhost).
I try to connect to the DB using this code:
$hostname_fb2 = "mysqldb.000webhost.com";
$database_fb2 = "my_db";
$username_fb2 = "my_user_name";
$password_fb2 = "my_pass";
$fb2 = mysql_pconnect($hostname_fb2, $username_fb2, $password_fb2) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_fb2, $fb2);
$result = mysql_query("select * from users where id='". $my_id ."';",$fb2);
Generates this error message (after waiting some time on white screen):
Warning: mysql_pconnect(): Lost connection to MySQL server at 'reading initial communication packet', system error: 110 in /app/www/fb2.php on line 9 Fatal error: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 in /app/www/fb2.php on line 9
So... is there a way to connect the 000webhost's MySQL server, through Heroku?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Heroku 不会限制您可以连接到 Heroku 外部的服务,因为它们允许使用许多它们本身不提供的插件/服务,例如 sendgrid、redistogo、xeroud
您是否能够连接到您现有的mysql 数据库来自本地计算机上的客户端工具(sequel pro、mysql 管理工具等) - 问题似乎更可能是它们阻止您访问数据库,而不是 Heroku 限制它。
Heroku don't tend to limit the services you can connect to outside of Heroku since they allow the use of lots of addons/services themselves that they don't provide, eg, sendgrid, redistogo, xeroud
Are you able to connect to your existing mysql database from client tools (sequel pro, mysql admin tools etc) on your local machine - it would seem more likely that the problem is more them preventing you accessing your DB as opposed to Heroku limiting it.