Mic*_*alB 121 mysql phpmyadmin
假设有一个远程服务器,我的计算机上安装了phpMyAdmin客户端.如何通过phpMyAdmin客户端访问此服务器并进行管理?那可能吗?
Sur*_*shi 157
只需将以下行添加到底部的"config.inc.php"文件中:
$i++;
$cfg['Servers'][$i]['host'] = 'HostName:port'; //provide hostname and port if other than default
$cfg['Servers'][$i]['user'] = 'userName'; //user name for your remote server
$cfg['Servers'][$i]['password'] = 'Password'; //password
$cfg['Servers'][$i]['auth_type'] = 'config'; // keep it as config
Run Code Online (Sandbox Code Playgroud)
.您将获得"当前服务器:",同时下载"127.0.0.1"和您提供的"$ cfg ['Servers'] [$ i] ['host']"服务器之间的凸轮切换.
更多详情:http://sforsuresh.in/access-remote-mysql-server-using-local-phpmyadmin/
Phi*_*oss 22
它可以完成,但你需要更改phpMyAdmin配置,请阅读这篇文章:http: //www.danielmois.com/article/Manage_remote_databases_from_localhost_with_phpMyAdmin
如果链接因任何原因而死亡,您可以使用以下步骤:
config.inc.php$cfg['Servers'][$i]['host']变量,并将其设置为远程服务器的IP或主机名$cfg['Servers'][$i]['port']变量,并将其设置为远程mysql端口.通常这是3306$cfg['Servers'][$i]['user']和$cfg['Servers'][$i]['password']变量并将其设置为远程服务器的用户名和密码如果没有正确的服务器配置,连接可能比本地连接慢,例如,使用IP地址而不是主机名可能会稍快一些,以避免服务器必须从主机名中查找IP地址.
此外,请记住,当您像这样连接时,您的远程数据库的用户名和密码以纯文本格式存储,因此您应该采取措施确保没有人可以访问此配置文件.或者,您可以将用户名和密码变量留空,以便在每次登录时提示输入它们,这样更安全.
c.h*_*ill 19
正如其他答案所指出的那样,当然可以从phpMyAdmin的本地实例访问远程MySQL服务器.为了实现这一点,您必须配置远程服务器的MySQL服务器以接受远程连接,并允许通过防火墙的流量获取MySQL正在侦听的端口号.我更喜欢涉及SSH隧道的略有不同的解决方案.
以下命令将设置SSH隧道,该隧道将从端口3307发出的所有请求从本地计算机转发到远程计算机上的端口3306:
ssh -NL 3307:localhost:3306 root@REMOTE_HOST
Run Code Online (Sandbox Code Playgroud)
出现提示时,您应该在远程计算机上输入root用户的密码.这将打开隧道.如果要在后台运行此命令,则需要添加-f参数,并在本地计算机和远程计算机之间设置无密码SSH.
在SSH隧道工作之后,您可以通过修改/etc/phpmyadmin/config.inc.php文件将远程服务器添加到本地phpMyAdmin中的服务器列表中.将以下内容添加到文件末尾:
$cfg['Servers'][$i]['verbose'] = 'Remote Server 1';// Change this to whatever you like.
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$i++;
Run Code Online (Sandbox Code Playgroud)
如果你需要额外的帮助,我写了一篇关于这个问题的更深入的博客文章.
Dul*_*ika 11
关注此博文.你可以很容易地做到这一点. https://wadsashika.wordpress.com/2015/01/06/manage-remote-mysql-database-locally-using-phpmyadmin/
config.inc.php文件包含phpMyAdmin安装的配置设置.它使用一个数组来存储它可以连接的每个服务器的配置选项集,默认情况下只有一个,你自己的机器或localhost.要连接到另一台服务器,您必须向配置阵列添加另一组配置选项.您必须编辑此配置文件.
首先打开phpMyAdmin文件夹中保存的config.inc.php文件.在wamp服务器中,您可以在wamp\apps\phpmyadmin文件夹中找到它.然后将以下部分添加到该文件中.
$i++;
$cfg['Servers'][$i]['host'] = 'hostname/Ip Adress';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'password';
Run Code Online (Sandbox Code Playgroud)
让我们看看这个变量的含义是什么.
$i++ :- Incrementing variable for each server
$cfg[‘Servers’][$i][‘host’] :- Server host name or IP adress
$cfg[‘Servers’][$i][‘port’] :- MySQL port (Leave a blank for default port. Default MySQL port is 3306)
$cfg[‘Servers’][$i][‘socket’] :- Path to the socket (Leave a blank for default socket)
$cfg[‘Servers’][$i][‘connect_type’] :- How to connect to MySQL server (‘tcp’ or ‘socket’)
$cfg[‘Servers’][$i][‘extension’] :- php MySQL extension to use (‘mysql’ or ‘msqli’)
$cfg[‘Servers’][$i][‘compress’] :- Use compressed protocol for the MySQL connection (requires PHP >= 4.3.0)
$cfg[‘Servers’][$i][‘auth_type’] :- Method of Authentication
$cfg[‘Servers’][$i][‘username’] :- Username to the MySQL database in remote server
$cfg[‘Servers’][$i][‘password’] :- Password to the MySQL database int he remote server
Run Code Online (Sandbox Code Playgroud)
添加此配置部分后,重新启动服务器,现在您的phpMyAdmin主页将更改,它将显示一个字段以选择服务器.
现在,您可以通过输入该数据库的用户名和密码来选择服务器并访问远程数据库.
如答案c.hill回答中所述,如果您需要安全的解决方案,我建议您打开到您的服务器的SSH隧道.
以下是为Windows用户执行此操作的方法:
从Putty网站下载Plink和Putty ,并将文件放在您选择的文件夹中(在我的示例中C:\Putty)
打开Windows控制台并cd到Plink文件夹:
cd C:\Putty
打开SSH隧道并重定向到端口3307:
plink -L 3307:localhost:3306 username@server_ip -i path_to_your_private_key.ppk
哪里:
最后你可以设置PhpMyAdmin:
要添加的行:
$i++;
$cfg['Servers'][$i]['verbose'] = 'Remote Dev server';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
Run Code Online (Sandbox Code Playgroud)
http://127.0.0.1/phpmyadmin如果您不想在每次需要连接到远程服务器时打开控制台,只需创建批处理文件(通过在.bat文件中保存2个命令行).
您可以在phpMyAdmin安装的config.inc.php文件中进行设置.
$cfg['Servers'][$i]['host'] = '';
Run Code Online (Sandbox Code Playgroud)
本来可以将此添加为评论,但是我的声誉还不够高。
在版本4.5.4.1deb2ubuntu2下,我猜在其他任何版本4.5.x或更高版本中。根本不需要修改config.inc.php文件。而是在conf.d下再走一个目录。
创建一个扩展名为'.php'的新文件并添加代码行。这是一种更好的模块化方法,可以隔离每个远程数据库服务器访问信息。
| 归档时间: |
|
| 查看次数: |
248942 次 |
| 最近记录: |