duanguangwang5829 2014-07-18 10:08 采纳率: 0%
浏览 149
已采纳

如何连接数据库(未知主机,没有ip)

I have a database hosted by one.com with these settings:

PhpMyAdmin: https://dbadmin.one.com

Host: axelerate.be.mysql

Database: axelerate_be

Username: axelerate_be

Password: *****

I want to make connection with this database by using a php file runned by the LXTerminal of the raspberry pi. When i try to make connection i get this error (host unknown):

Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\xampp\htdocs\twitter\index.php on line 3

Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\xampp\htdocs\twitter\index.php on line 3 Failed to connect to MySQL: php_network_getaddresses: getaddrinfo failed: Host is onbekend.

This is my code:

<?php
    // Create connection
    $con=mysqli_connect("axelerate.be.mysql","axelerate_be","*******","axelerate_be");

    // Check connection
    if (mysqli_connect_errno()) {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }else{
        echo "it works!";
    }
?>

My question:

How can i make this connection work without edditing any config files? (so if there is something to do, I want only to write in the php file)

Thanks!

  • 写回答

3条回答 默认 最新

  • dongzhuange2625 2014-07-18 10:26
    关注

    The .mysql based hosts are internal hosts within the one.com network that resolves to the server that hosts your database. These hosts are not meant for connections outside of one.com hosting, and probably doesn't accept connections from the world if they're even available on a public IP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图