[英]Auto-login phpMyAdmin
我们想在 phpMyAdmin 中自动登录用户。 现在我们有了一个用 PHP 编写的 Web 界面。 用户可以登录。 登录后,他们可以单击打开 phpMyAdmin 的菜单中的SQL
链接。 有没有办法让他们自动登录? 是否可以为 phpMyAdmin 设置 cookie 或让他们使用它的东西? 我们不想关闭 phpMyAdmin 的登录; 每个用户都有自己的 MySQL 用户/密码组合。 所以我们需要将用户名/密码设置传递给 phpMyAdmin。
在 /* Authentication type */ 下面的 config.inc.php 中添加代码。 它存在于根文件夹中
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
编辑 config.inc.php
位置:/etc/phpmyadmin/config.inc.php
查找打击代码
$cfg['Servers'][$i]['auth_type'] = 'cookie';
并用吹码替换代码行
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_password';
如果您的密码为 null 或 '' 取消注释吹线
//$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
到
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
然后它会正常工作!
你可以简单地张贴在字段中指定的用户名pma_username
和密码pma_password
。 或者,如果您使用 http 身份验证模式,您可以创建一个包含用户名和密码的链接,例如http://user:pass@www.host.com/phpmyadmin/...
配置文件
/* Authentication type */
//$_SERVER["REMOTE_ADDR"] == '::1' (**ipv6**)
//$_SERVER["REMOTE_ADDR"] == '127.0.0.1' (**ipv4**)
if ($_SERVER["REMOTE_ADDR"] == '::1') {
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'user';
$cfg['Servers'][$i]['password'] = 'password';
} else {
$cfg['Servers'][$i]['auth_type'] = 'cookie';
}
有时在您的本地环境中工作时,每次登录都很烦人。 为了避免它,您可以执行以下操作:
在文件底部添加以下几行:
phpmyadmin\\config.inc.php
$cfg['LoginCookieValidity'] = 10000; // Keep long validity :)-
$cfg['Servers'][$i]['user'] = 'root'; // Your user name
$cfg['Servers'][$i]['password'] = 'root'; // Your password
$cfg['Servers'][$i]['auth_type'] = 'config';
之后关闭您的数据库服务器并重新启动。 现在检查&您将看到您无需输入用户名和密码即可登录。
如果您需要它进行开发,那么 2020 年的事情会容易得多。 只需设置环境变量:
PMA_USER: "the-root"
PMA_PASSWORD: "the-password"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.