[英]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.