从本地计算机连接到GoDaddy服务器数据库 [英] Connect to GoDaddy server database from localhost computer

查看:85
本文介绍了从本地计算机连接到GoDaddy服务器数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用PHP编写了一个网站,该PHP通过GoDaddy使用MySQL服务器。我将相同的代码保存在本地计算机上,并通过应用程序将其与GoDaddy上的目录同步。在公开发布更改之前,我还使用计算机上的XAMPP来测试对网站所做的任何更改。但是, localhost 服务器是不同的,并且绝不与cPanel GoDaddy服务器连接。因此,如果在公用服务器上的数据库中添加了新内容,我将不得不

I programmed a website in PHP that uses a MySQL Server through GoDaddy. I have the same code saved on my local computer and sync it with the directory on GoDaddy through an app. I also use XAMPP on my computer to test any changes I make to the website before I make the changes public. However, the localhost server is different and in no way connected with the cPanel GoDaddy server. Therefore, if something new is added to the database on the public server, I would have to


  1. 在远程phpmyadmin上下载sql文件

  2. 将此文件上传到localhost phpmyadmin

这是一个效率低下的过程,所以现在我要使用PHP连接到GoDaddy服务器。为此,我将提供给我的IP地址作为 mysqli_connect()函数的主机参数放在GoDaddy托管页面中。

This is an inefficient process, so now I want to use PHP to connect to the GoDaddy server. To do this, I put the IP Address given to me in the GoDaddy hosting page as the host parameter of the mysqli_connect() function.

// Set the database access information as constants
define('DB_USER', 'libuc6kfb0jg');
define('DB_PASSWORD', 'MY PASSWORD');
define('DB_HOST', 'MY IP ADDRESS');
define('DB_NAME', 'firstborumdatabase');

此用户在远程主机和本地主机上均具有所有特权。
cPanel-远程MySQL®上,我已经添加了计算机本地主机服务器的IP地址。

This user has all privileges on both the remote and the localhost. On cPanel - Remote MySQL® I have added the IP Address of my computer's localhost server.

// Make the connection
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySQL: ' . mysqli_connect_error());

当我输入此代码时,不是以 localhost作为主机,而是连接到XAMPP的本地MySQL服务器,它给出以下错误

When I put this code in, instead of having 'localhost' as my host, which connects to the local MySQL server of XAMPP, it gives the following error


无法连接到MySQL:用户'libuc6kfb0jg'@'的访问被拒绝[敏感信息](使用密码:是)

Could not connect to MySQL: Access denied for user 'libuc6kfb0jg'@'[Sensitive Info]' (using password: YES)

由于我知道这不是权限问题,所以我接下来要做的就是使用PORT参数。因此,我最后添加3306无济于事,因为它给了我同样的错误。最后,我将此代码作为 mysql 命令从XAMPP控制面板放入mysql客户端,这给了我相同的确切错误。

Since I know it is not a permissions problem, the next thing I did was use the PORT parameter. So, I added 3306 to the end to no avail, for it gave me the same error. Lastly, I put in this code as a mysql command into the mysql client from the XAMPP Control Panel, and this gave me the same exact error.

堆栈溢出研究

  • Connect to server database from localhost does not give the same error as me
  • Connecting to online MySQL database from localhost: I tried changing www.bforborum.com to the its ip address from the GoDaddy My Hosting Page, and this gave the same error
  • Can't connect to godaddy localhost is answered with the same code that I used except using the PDO api and not the mysqli api
  • Connecting remote server mysql database to localhost doesn't give any code

任何帮助将不胜感激。

编辑

我发现了一个缺陷:在cPanel,远程MySQL数据库中,我添加了如果可以的话,我的本地主机服务器的IP地址,而不是我计算机的IP地址。我现在正在更改在此工具中添加的IP地址。

I found a flaw: In cPanel, Remote MySQL Database, I added the IP Address that my localhost server is, not my computer's IP Address, if that makes sense. I am now changing the IP Address that I had added in this tool.

推荐答案

向用户授予所有权限对于使其具有对数据库的必要访问权限至关重要,而这仅会影响到他的能力操纵数据库。您还需要使用服务器防火墙将计算机IP列入白名单,否则将无法连接到远程服务器。

While giving the user all permissions is crucial for it to have the necessary access to your database that only affects the ability for him to manipulate the database. You need to also whitelist your computers IP with the Servers firewall or you will not be allowed to connect to the remote server.

这篇关于从本地计算机连接到GoDaddy服务器数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆