简体   繁体   English

远程 SQL 连接:mysqli_connect():(HY000/1045):用户拒绝访问

[英]Remote SQL connection: mysqli_connect(): (HY000/1045): Access denied for user

I have a database that I want to transfer to my remote server from localhost.我有一个数据库,我想从本地主机传输到我的远程服务器。 The file being too big, I wrote the code to copy the table.文件太大,我写了代码来复制表。 But the problem the connection is not successful.但问题是连接不成功。 My code looks like this.我的代码看起来像这样。

$server_conn=mysqli_connect($db_host,$db_user,$db_pass,$db_name);
if (!$server_conn) {
    die("Server Connection Fail: " . mysqli_connect_error());
} 

Where $db_host is the ip address of my server.其中$db_host是我服务器的 IP 地址。

When I load the script the error I get is当我加载脚本时,我得到的错误是

Server Connection Fail: Access denied for user db_user@'117.202.126.83' (using password: YES)服务器连接失败:用户 db_user@'117.202.126.83' 的访问被拒绝(使用密码:是)

The credentials are correct, the host is correct, and the weirdest part is 117.202.126.83 is my IP address.凭据正确,主机正确,最奇怪的部分是117.202.126.83是我的 IP 地址。

I don't know how is it ignoring the host and taking my connection IP address for host.我不知道它是如何忽略主机并为主机获取我的连接 IP 地址的。 Even when I give the db_host as the IP address of my remote server.即使我将 db_host 作为远程服务器的 IP 地址。

Also, I am running the script using Easy PHP 14.1 running APACHE 2.4.7,MYSQL 5.6.15 and PHP 5.4.24.此外,我正在使用运行 APACHE 2.4.7、MYSQL 5.6.15 和 PHP 5.4.24 的 Easy PHP 14.1 运行脚本。

What am I missing?我错过了什么?

UPDATE : I am not sure if I was stupid or if the hostgator instructions were.更新:我不确定我是愚蠢还是hostgator 说明是愚蠢的。 They ask us to add the cpanel username followed by an underscore before the database name and database username.他们要求我们在数据库名称和数据库用户名之前添加后跟下划线的 cpanel 用户名。 In the cpanel, the cpanel username is prefixed by force to all user and db names.在 cpanel 中,cpanel 用户名被强制作为所有用户和数据库名称的前缀。 So in my case, I had the variables as cpanelUsername_cpanelUsername_databaseName and so on.所以在我的例子中,我的变量是cpanelUsername_cpanelUsername_databaseName等等。

Thank you guys for your replies谢谢大家的回复

Go to the cpanel where your phpMyAdmin has the access.转到您的 phpMyAdmin 有权访问的 cpanel。 Click on Remote MySQL Add the access host (Your local IP which is running the script) Then you can get access to remote mysql server.单击远程 MySQL 添加访问主机(运行脚本的本地 IP)然后您可以访问远程 mysql 服务器。 You can then test the connection using MySQL Workbench ()然后可以使用 MySQL Workbench() 测试连接

转到控制面板 在此处输入图片说明

你确定你使用了正确的外部数据库主机名/ip吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (使用密码: NO) - mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) WampServer, mysqli_connect (HY000/1045) 用户访问被拒绝 - WampServer, mysqli_connect (HY000/1045) Access denied for user 警告:mysqli_connect(): (HY000/1045): 用户 'usr'@'localhost' 访问被拒绝(使用密码:YES) - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'usr'@'localhost' (using password: YES) 警告:mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) 警告:mysqli_connect():(HY000/1045):用户'root'@'localhost'的访问被拒绝(使用密码:YES)无法连接数据库 - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) Could not connect database 警告:mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp64\www\web\db.php 在第 3 行 - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp64\www\web\db.php on line 3 PHP:可以在浏览器中拒绝终端访问(警告:mysqli::__construct():(HY000/1045):拒绝用户'root'@'localhost'访问 - PHP: can connect in terminal access denied in browser (Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' 警告:mysqli_connect():( HY000 / 2002):拒绝连接 - Warning: mysqli_connect(): (HY000/2002): Connection refused in mysqli_real_connect(): (HY000/1045): Access denied for user 'admin'@'localhost' (using password: YES) wordpress - mysqli_real_connect(): (HY000/1045): Access denied for user 'admin'@'localhost' (using password: YES) wordpress mysqli_connect(): (HY000/2002): 与远程服务器的连接尝试失败 - mysqli_connect(): (HY000/2002): A connection attempt failed to the remote server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM