无法从虚拟主机本身以外的任何地方连接到任何虚拟主机的 MySQL 数据库 [英] Can't connect to MySQL databse of any webhost from anywhere other than the webhost itself

查看:35
本文介绍了无法从虚拟主机本身以外的任何地方连接到任何虚拟主机的 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个不同的虚拟主机(pagodabox & 000webhost,都是免费的)并且我已经用 MySQL 设置了一个 localhost.

I have 2 different webhost (pagodabox & 000webhost, both free) and I've set up a localhost with MySQL.

我已经在他们三个上都安装了 wordpress,它们在他们自己的域内运行良好——即.当 localhost wordpress 使用 localhost 数据库时,pagodabox 使用 pagodabox 数据库等等.

I've installed wordpress on all three of them which work perfectly fine within their own domain -- ie. when localhost wordpress is using localhost database, pagodabox is using pagodabox database and so on.

但是,如果我从 wp-config.php 更改数据库访问凭据,以便让 localhost wordpress 连接到 000webhost 数据库,它不起作用:建立数据库时出错".

However if I change database access credentials from wp-config.php in order to, say, make localhost wordpress connect to 000webhost database, it doesn't work: "Error establishing database".

这是我使用的相应凭据:

Here's the respective credentials I use:

<?php

wp-config.php - relevant differences

* members.000webhost.com/panel/Manage MySQL Databases    
    // ** MySQL settings - You can get this info from your web host ** //    
    /** The name of the database for WordPress */    
    define('DB_NAME', '--------_db');    
    /** MySQL database username */    
    define('DB_USER', '--------');    
    /** MySQL database password */    
    define('DB_PASSWORD', '--------');    
    /** MySQL hostname */    
    define('DB_HOST', 'mysq--.000webhost.com');    

* tunnel.pagodabox.com
    // ** MySQL settings - You can get this info from your web host ** //    
    /** The name of the database for WordPress */    
    define('DB_NAME', '--------_db');    
    /** MySQL database username */    
    define('DB_USER', '--------');    
    /** MySQL database password */    
    define('DB_PASSWORD', '--------');    
    /** MySQL hostname */    
    define('DB_HOST', 'tunnel.pagodabox.com');    

* localhost    
    // ** MySQL settings - You can get this info from your web host ** //    
    /** The name of the database for WordPress */    
    define('DB_NAME', '--------_db');    
    /** MySQL database username */    
    define('DB_USER', '--------');    
    /** MySQL database password */    
    define('DB_PASSWORD', '--------');    
    /** MySQL hostname */    
    define('DB_HOST', 'localhost');    

?>

推荐答案

如果您有 cPanel,并且在您的 cPanel 中启用了远程 MySQL",那么..

If you have cPanel, and "Remote MySQL" is enabled in your cPanel, then..

您可以允许外部网络服务器访问您的 MySQL 数据库,方法是将其域名添加到能够访问您网站上的数据库的主机列表中.

You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site.

不过,我猜您正在尝试从本地计算机连接到 000webhost.我认为您不能这样做,因为 cPanel 不会将其视为有效主机.

However I guess you are trying to connect to 000webhost from your local computer. I don't think you can do that because cPanel won't consider it a valid host.

这篇关于无法从虚拟主机本身以外的任何地方连接到任何虚拟主机的 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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