PHPMyAdmin - 为多个数据库设置全局用户和密码

时间:2013-06-02 17:19:55

标签: php sql phpmyadmin config

我想做我的支持数据库。我有config.inc.php文件信息登录我的数据库(主机,登录,密码)。

但我想为所有已定义的数据库设置全局用户。所以我写了全局登录名和密码,可以管理我所定义的所有数据库。但我不知道怎么做?

这是我的config.inc.php片段:

/*
 * Servers configuration
 */
$i = 0;

/* Authentication type */
$i++;
$cfg['Servers'][$i]['user'] = 'global user';
$cfg['Servers'][$i]['password'] = 'password global user\'s'; // use here your password
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/* Server parameters */
$i++;
$cfg['Servers'][$i]['host'] = 'host.frist.database';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['user'] = 'user.frist.bazy';
$cfg['Servers'][$i]['password'] = 'password.frist.database';

$i++;
$cfg['Servers'][$i]['host'] = 'host.second.database';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['user'] = 'user.second.bazy';
$cfg['Servers'][$i]['password'] = 'password.second.database';

我不知道,怎么做......

1 个答案:

答案 0 :(得分:0)

必须将“全局”配置存储在单独的阵列中,并将其用作每个服务器的默认设置,例如像这样:

$global['user'] = 'global user';
$global['password'] = 'password global user\'s'; // use here your password
$global['auth_type'] = 'config';
$global['AllowNoPassword'] = false;

/*
 * Servers configuration
 */
$i = 0;


$i++;
$cfg['Servers'][$i] = $global;
/* individual config for first server */
$cfg['Servers'][$i]['host'] = 'host.frist.database';
$cfg['Servers'][$i]['user'] = 'user.frist.bazy';
$cfg['Servers'][$i]['password'] = 'password.frist.database';


$i++;
$cfg['Servers'][$i] = $global;
/* individual config for second server */
$cfg['Servers'][$i]['host'] = 'host.second.database';
$cfg['Servers'][$i]['user'] = 'user.second.bazy';
$cfg['Servers'][$i]['password'] = 'password.second.database';