简体   繁体   English

远程连接到 mysql db 与 php?

[英]remotley connect to mysql db with php?

i'v built a huge media player with more than 250gigs of music and still growing( it's legal ).我已经建立了一个巨大的媒体播放器,里面有超过 250 的音乐并且还在增长(这是合法的)。

so i need "unlimited" disk space and "unlimited" mysql concurrent connections, and i can get that with dedicated server but it's to much money for me.所以我需要“无限”磁盘空间和“无限”mysql 并发连接,我可以通过专用服务器获得,但这对我来说太贵了。

so after i stayed on the line with HostGator sales for hour + they gave me this offer..因此,在我与 HostGator 销售人员保持联系一小时后,他们给了我这个提议。

"you could have an Shared Hosting account with the databases, and just remotely access them from the VPS, but that would be out of scope for us to really help set it up" “您可以拥有数据库的共享主机帐户,然后从 VPS 远程访问它们,但这将超出 scope 让我们真正帮助设置它”

so the offer they came back with was that i buy VPS package and Shared Hosting Package.所以他们回来的报价是我购买 VPS package 和共享主机 Package。

the VPS package have no "limit" on mysql connections . VPS package 对 mysql 连接没有“限制” > the site will be on this account. > 该网站将在此帐户上。

the Shared Hosting will have no limit on "Disk Space" .共享主机对“磁盘空间”没有限制 > the files and the mysql server will be on this account. > 文件和 mysql 服务器将在此帐户上。

so how can i remotely connect to the mysql db with php?那么如何使用 php 远程连接到 mysql db?

Can u guys help me?你们能帮帮我吗?

Why don't you put the PHP files and MySql on the VPS and just the music files on the Shared Hosting account?你为什么不把 PHP 文件和 MySql 放在 VPS 上,只把音乐文件放在共享主机帐户上? You could access the database from the Shared Hosting if they allow remote access to the MySql port.如果他们允许远程访问 MySql 端口,您可以从共享主机访问数据库。 It doesn't really make sense if they said the VPS had unlimited MySql connections if they didn't mean for you to put the db there.如果他们说 VPS 有无限的 MySql 连接,如果他们不打算让你把数据库放在那里,那真的没有意义。

$connect = mysql_connect($server_addr, $username, $password);

Where $server_addr is the remote IP address or domain name of the SQL server, $username is the SQL username and $password is the password for the specified username.其中$server_addr是SQL服务器的远程IP地址或域名, $username是SQL用户名, $password是密码。 Most hosting packages (especially those running on cPanel) require you to specify remote addresses which can connect to the server with your account .大多数托管程序包(尤其是在 cPanel 上运行的程序包)都要求您指定可以使用您的帐户连接到服务器的远程地址

if they offer ssh access, you could create a tunnel over ssh for the mysql port.如果他们提供 ssh 访问权限,您可以在 ssh 上为 mysql 端口创建隧道。 other options are a vpn (virtual private network) between the computers其他选项是计算机之间的 vpn(虚拟专用网络)

also if the are both hosted by the same company, they might be behind the same firewall then there is the possibility you can connect directly to the other box此外,如果它们都由同一家公司托管,它们可能位于同一防火墙后面,那么您可以直接连接到另一个盒子

eg host = ipaddress of server with database on it例如,主机 = 带有数据库的服务器的 IP 地址

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM