phpmyadmin设置多个不同服务器的数据库

64 篇文章 4 订阅

phpmyadmin是非常强大并且好用的工具,就是界面有点丑陋。以前不怎么用,现在看到身边好几个同事都在用这个,如是决定尝试一下,敲命令会有各种提示,表名搜索过滤,尤其是表很多的时候,这个就显得非常方便了。
复制phpmyadmin根目录下面的config.sample.inc.php

cp config.sample.inc.php  config.inc.php

修改其内容如下:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use setup/
 *
 * All directives are explained in documentation in the doc/ folder
 * or at <https://docs.phpmyadmin.net/>.
 *
 * @package PhpMyAdmin
 */

/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = 'sedauthordin*ce.Nexxxxobe32chars'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

//这里把远程服务器的用户名,密码等,拼接为一个多维数组
$connect_hosts = array(
    4 => array(
        "host" => "xxx", //xx测试环境服务器
        "user" => "xxx",
        "password" => "password",
        "verbose" => "xx-uat",
        "only_db" => "xxx",#只显示的数据库
    ),
    5 => array(
        "host" => "xxx", //xx测试环境服务器
        "user" => "xxx",
        "password" => "password",
        "verbose" => "xx-uat",
        "only_db" => "xxx",#只显示的数据库
    ),
    6 => array(
        "host" => "xxx", //xx测试环境服务器
        "user" => "xxx",
        "password" => "password",
        "verbose" => "xx-uat",
        "only_db" => "xxx",#只显示的数据库
    ),
);
$hosts = count($connect_hosts);
for ($i = 1; $i <= $hosts; $i++) {
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'config';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = $connect_hosts[$i]['host']; //修改host
    $cfg['Servers'][$i]['user'] = $connect_hosts[$i]['user']; //修改用户名
    $cfg['Servers'][$i]['password'] = $connect_hosts[$i]['password']; //密码
    $cfg['Servers'][$i]['verbose'] = $connect_hosts[$i]['verbose']; //数据库别名
}

这样就可以随时切换数据库了。另外phpmyadmin是可以查看历史sql记录的,点开左下角的控制台,右侧就会有显示历史。鼠标移动到执行过的sql上面会出现再次执行,分析sql等选项。
在这里插入图片描述

phpmyadmin中文手册

遇到的问题:
phpmyadmin 配置文件权限错误,不应任何用户都能修改!

措施一:

修改文件权限
chmod 755 config.inc.php

措施二:

关闭权限检查

D:\WWW\phpMyAdmin-5.0.2\config.inc.php

如果是虚拟机,不能修改文件权限就把配置文件权限检查关闭:
修改如下:

$cfg['CheckConfigurationPermissions'] = false;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SHUIPING_YANG

你的鼓励是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值