加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在Windows主机上连接到godaddy数据库时,用户拒绝访问?

发布时间:2020-12-13 21:54:18 所属栏目:PHP教程 来源:网络整理
导读:我在Godaddy windows托管上制作简单的 mysqli连接到我的数据库,我的代码如下: ?php error_reporting(E_ALL ~(E_STRICT|E_NOTICE)); $host = 'localhost'; $user = 'root_user_name'; $password = 'root_user_pass'; $db = 'my_database'; $cxn = mysqli_con
我在Godaddy windows托管上制作简单的 mysqli连接到我的数据库,我的代码如下:

<?php 

        error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));

            $host = 'localhost'; 
            $user = 'root_user_name'; 
            $password = 'root_user_pass'; 
            $db = 'my_database'; 
            $cxn = mysqli_connect($host,$user,$password) or 
                     die(mysqli_connect_error()); // <<<<<< line 9
            mysqli_select_db($cxn,$db ) or die(mysqli_connect_error()); 


        die('test');

我确定授予的用户名和密码以及数据库名称,我的所有凭据都是正确的,但我收到此错误:

Warning: mysqli_connect(): (HY000/1045): Access denied for user
‘root_user_name’@’localhost’ (using password: YES) in
G:pathtofileindex.php
on line 9 Access denied for user ‘root_user_name’@’localhost’ (using
password: YES)

我使用wamp服务器在localhost上使用相同的数据库名称和凭据,我没有太多进入IIS服务器和Windows托管..任何帮助将不胜感激.

解决方法

我曾经遇到过这个问题,只需在连接数据库时设置主机中数据库服务器的真实IP地址即可解决.要获取IP地址,请登录您的主机帐户并访问数据库,然后单击管理您想要的数据库,这将带您到phpMyAdmin.在右侧有一个标题为Database Server的块,您可以在第一个列表项中找到服务器IP地址.在$host而不是localhost中使用它:

$host = '51.51.51.51'; // <<<< just a fake IP address for the example

我有很多艰难的时间来找出问题所在,我甚至联系了支持部门并得到了这个回复:

Joshua – I think the permissions are the cause of the issue. Once you
have them properly updated,the problem should go away.

他们说文件权限可能是问题,我更新了文件权限但没有解决它.

有时解决方案比您想象的更接近!!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读