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

将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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配