使用 phpMyAdmin 连接到外部服务器

发布于 2024-08-11 03:55:10 字数 43 浏览 3 评论 0原文

我在本地计算机上安装了 phpMyAdmin。如何让它连接到外部服务器?

I have phpMyAdmin installed on my local machine. How can I make it connect to an external server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

活泼老夫 2024-08-18 03:55:10

在配置文件中,将“host”变量更改为指向外部服务器。配置文件名为 config.inc.php,位于 phpMyAdmin 主文件夹中。应该有这样一行:

$cfg['Servers'][$i]['host'] = 'localhost';

只需将 localhost 更改为您服务器的 IP 地址。

注意:您可能必须配置外部服务器以允许远程连接,但我已经在共享主机上这样做了几次,所以应该没问题。

In the config file, change the "host" variable to point to the external server. The config file is called config.inc.php and it will be in the main phpMyAdmin folder. There should be a line like this:

$cfg['Servers'][$i]['host'] = 'localhost';

Just change localhost to your server's IP address.

Note: you may have to configure the external server to allow remote connections, but I've done this several times on shared hosting so it should be fine.

朮生 2024-08-18 03:55:10

要设置外部数据库并仍然使用本地数据库,您需要编辑 config.inc.php 文件:

On Ubuntu: sudo gedit /etc/phpmyadmin/config.inc.php

该文件大致设置如下:

if (!empty($dbname)) {

    //Your local db setup

     $i++;
}

您需要做的是通过复制来复制“您的本地数据库设置”并将其粘贴到我在下面的代码中显示的 IF 语句的外部,并将主机更改为您的外部 IP。我的例子是:

$cfg['Servers'][$i]['host'] = '10.10.1.90:23306';

您可以保留默认值(除非您知道需要更改它们)

保存并刷新您的 PHPMYADMIN 登录页面,然后应该会出现一个新的下拉列表。你应该可以走了。


编辑:如果您想为服务器指定一个名称以在登录页面选择,而不仅仅是选择 IP 地址,请将其添加到服务器设置中:

$cfg['Servers'][$i]['verbose'] = 'Name to show when selecting your server'; 

如果您有多个服务器配置,那就太好了。

To set up an external DB and still use your local DB, you need to edit the config.inc.php file:

On Ubuntu: sudo gedit /etc/phpmyadmin/config.inc.php

The file is roughly set up like this:

if (!empty($dbname)) {

    //Your local db setup

     $i++;
}

What you need to do is duplicate the "your local db setup" by copying and pasting it outside of the IF statement I've shown in the code below, and change the host to you external IP. Mine for example is:

$cfg['Servers'][$i]['host'] = '10.10.1.90:23306';

You can leave the defaults (unless you know you need to change them)

Save and refresh your PHPMYADMIN login page and a new dropdown should appear. You should be good to go.


EDIT: if you want to give the server a name to select at login page, rather than having just the IP address to select, add this to the server setup:

$cfg['Servers'][$i]['verbose'] = 'Name to show when selecting your server'; 

It's good if you have multiple server configs.

遗弃M 2024-08-18 03:55:10

使用 PhpMyAdmin 版本 4.5.4.1deb2ubuntu2,您可以在 /etc/phpmyadmin/config-db.php 中设置变量,

因此将 $dbserver 设置为您的服务器名称,例如 $dbserver='mysql.example.com';

<?php
##
## database access settings in php format
## automatically generated from /etc/dbconfig-common/phpmyadmin.conf
## by /usr/sbin/dbconfig-generate-include
##
## by default this file is managed via ucf, so you shouldn't have to
## worry about manual changes being silently discarded.  *however*,
## you'll probably also want to edit the configuration file mentioned
## above too.
##
$dbuser='phpmyadmin';
$dbpass='P@55w0rd';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='';
$dbtype='mysql';

using PhpMyAdmin version 4.5.4.1deb2ubuntu2, you can set the variables in /etc/phpmyadmin/config-db.php

so set $dbserver to your server name, e.g. $dbserver='mysql.example.com';

<?php
##
## database access settings in php format
## automatically generated from /etc/dbconfig-common/phpmyadmin.conf
## by /usr/sbin/dbconfig-generate-include
##
## by default this file is managed via ucf, so you shouldn't have to
## worry about manual changes being silently discarded.  *however*,
## you'll probably also want to edit the configuration file mentioned
## above too.
##
$dbuser='phpmyadmin';
$dbpass='P@55w0rd';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='';
$dbtype='mysql';
紫竹語嫣☆ 2024-08-18 03:55:10

在4.0或以上版本,我们需要创建一个'config.inc.php'或将'config.sample.inc.php'重命名为'config.inc.php';

就我而言,我还为每个环境(开发和生产)使用一台 mysql 服务器:

/* others code*/  
$whoIam = gethostname();
switch($whoIam) {
    case 'devHost':
        $cfg['Servers'][$i]['host'] = 'localhost';
        break;
    case 'MasterServer':
        $cfg['Servers'][$i]['host'] = 'masterMysqlServer';
        break;
} /* others code*/ 

at version 4.0 or above, we need to create one 'config.inc.php' or rename the 'config.sample.inc.php' to 'config.inc.php';

In my case, I also work with one mysql server for each environment (dev and production):

/* others code*/  
$whoIam = gethostname();
switch($whoIam) {
    case 'devHost':
        $cfg['Servers'][$i]['host'] = 'localhost';
        break;
    case 'MasterServer':
        $cfg['Servers'][$i]['host'] = 'masterMysqlServer';
        break;
} /* others code*/ 
抹茶夏天i‖ 2024-08-18 03:55:10

您可以使用 phpmyadmin 设置页面 (./phpmyadmin/setup) 为您生成一个新的配置文件 (config.inc.php)。该文件位于 phpMyAdmin 目录的根目录中。

只需按照设置页面中的提示创建配置文件夹,添加服务器,然后单击“保存”按钮即可。这将在您刚刚创建的配置文件夹中创建一个新的配置文件。

现在,您只需将 config.inc.php 文件移动到主 phpMyAdmin 文件夹,或者如果您已经完成了一些想要保留的旧配置,则只需复制有关服务器的行即可。

之后不要忘记删除 config 文件夹。

You can use the phpmyadmin setup page (./phpmyadmin/setup) to generate a new config file (config.inc.php) for you. This file is found at the root of the phpMyAdmin directory.

Just create the config folder as prompted in setup page, add your servers, then click the 'Save' button. This will create a new config file in the config folder you just created.

You now have only to move the config.inc.php file to the main phpMyAdmin folder, or just copy the lines concerning the servers if you got some old configuration done already you'd like to keep.

Don't forget to delete the config folder afterwards.

旧街凉风 2024-08-18 03:55:10

在 config.inc.php 中,删除所有包含 "$cfg['Servers']" 的行,并仅保留 "$cfg['Servers'][$i]['host']"

in the config.inc.php, remove all lines with "$cfg['Servers']" , and keep ONLY the "$cfg['Servers'][$i]['host']"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文