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