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

我在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:\path\to\file\index.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.

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

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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...