0

我想做我的支持数据库。我在 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';

不知道怎么弄

4

1 回答 1

0

Yust 将您的“全局”配置存储在一个单独的数组中,并将其用作每个服务器的默认值,例如:

$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';
于 2020-08-20T07:01:53.260 回答