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

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

问题描述

我有2个不同的虚拟主机(pagodabox000webhost,都是免费的),并且我已经用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数据库,则该操作不起作用: "Error establishing database" .

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..

您可以通过将外部域名添加到能够访问您网站上数据库的主机列表中来允许外部Web服务器访问您的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天全站免登陆