我们在不同的服务器上有大约 10 个数据库(并且还在增加),我们必须管理这些数据库并在它们之间快速切换,而且每次访问时不断输入每个服务器的密码变得非常低效。
我想实现对 phpMyAdmin 的全局用户名/密码访问。我曾尝试使用我们内部网现有的用户身份验证过程,该过程使用 PHP session ,但这会干扰 phpMyAdmin 对 session 的使用。
有什么办法可以做到这一点吗?插件? PMA 代码中是否有我需要注意的协议(protocol)?
基本上,我已经尝试将它插入到 config.inc.php
中,但它只是被忽略了:
if ( isset ( $_SESSION["myIntranetAuth"] ) and $_SESSION["myIntranetAuth"] == true)
{
$cfg['Servers'][$i]['host'] = 'remote.database.server.net';
$cfg['Servers'][$i]['user'] = 'database1';
$cfg['Servers'][$i]['password'] = 'Password123';
// etc - for all servers/databases
}
我也试过将它插入到 phpMyAdmin 的 index.php
顶部,但它也被忽略了:
if ( ! isset ( $_SESSION["myIntranetAuth"] ) or $_SESSION["myIntranetAuth"] != TRUE )
{
exit ( header( "Location: https://myintranet.com/login" ) );
}
我什至在这两种情况下都包含了 if( session_id() == "") session_start();
,但它告诉我:
Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "PMA_Theme_Manager" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /usr/www/users/me/myintranet.com/pma/libraries/common.inc.php on line 686
我是在打一场必败仗吗?
最佳答案
我不确定这个解决方案有多稳健或安全,但到目前为止它已经奏效了。欢迎任何警告。
我在 config.inc.php
中使用了以下内容:
if( session_id() == "" ) session_start();
if ( isset ( $_SESSION["myIntranetAuth"] ) and $_SESSION["myIntranetAuth"] == true)
{
$cfg['Servers'][$i]['host'] = 'remote.database.server.net';
$cfg['Servers'][$i]['user'] = 'database1';
$cfg['Servers'][$i]['password'] = 'Password123';
// etc - for all servers/databases
}
并注释掉 session.inc.php
中的 session_start()
(第 101 行,版本 4.3.8,否则未修改)以删除持久的“ session 已启动”消息.
关于php - 如何独立于 'linked' 服务器添加对 phpMyAdmin 的用户名/密码访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29028253/