dongyin4202 2014-03-26 17:43
浏览 210
已采纳

将PHP连接到MariaDB数据库时出错

I am trying to create a simple web app that prints out database info from MariaDB/MySQL using PHP, im not even at that stage yet... I have trouble when connecting to the database and get the following error:

Host '10.155.237.62' is not allowed to connect to this MariaDB server

Now, I have not done a secure installation so my Mariadb Server allows access from wildcard host and infact any host.I have also tried the code with the root account but received the same error. Can anyone tell me if its my code or whether its a procedure im not aware of that disallows connectors to access the information?

Here is my code:

<?php
$con=mysqli_connect("vm-007.server.com","testuser","testpass","my_db");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MariaDB: " . mysqli_connect_error();
  }
?>

Thanks in advance!

  • 写回答

3条回答 默认 最新

  • doujun7161 2014-03-26 17:56
    关注

    i would test your mysql database access from command line from remote machine

    mysql -h vm-007.server.com -u testuser my_db -p

    it will ask you for a password and type that in.

    If it fails then you are probably dealing with a mysql setup problem.

    likely you are dealing with something like the mysql daemon only listening to the localhost interface i.e. 127.0.0.1 . Even if it allows access from any host if it isn't listening to a give interface like eth0 it doesn't matter.

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

报告相同问题?

悬赏问题

  • ¥15 软件定义网络mininet和onos控制器问题
  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。