php 自动登录 phpMyAdmin
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5687970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Auto-login phpMyAdmin
提问by www.data-blogger.com
We want to auto login users in phpMyAdmin. Now we have a web-interface, written in PHP. Users can login. After logging in, they can click on the SQL
link in the menu that opens phpMyAdmin. Is there a way to log them in automatically? Is it possible to set cookies for phpMyAdmin or something to let them use it?
We don't want to turn off phpMyAdmin's login; each user has his own MySQL user/pass combination. So we need to pass the username/password settings to phpMyAdmin.
我们想在 phpMyAdmin 中自动登录用户。现在我们有了一个用 PHP 编写的 Web 界面。用户可以登录。登录后,他们可以单击SQL
打开 phpMyAdmin 的菜单中的链接。有没有办法让他们自动登录?是否可以为 phpMyAdmin 设置 cookie 或让他们使用它的东西?我们不想关闭 phpMyAdmin 的登录;每个用户都有自己的 MySQL 用户/密码组合。所以我们需要将用户名/密码设置传递给 phpMyAdmin。
采纳答案by markus
You can simply post the username in a field named pma_username
and the password in pma_password
. Or, if you're using http auth mode you can create a link with username and password like http://user:[email protected]/phpmyadmin/...
您可以简单地将用户名发布在名为的字段中pma_username
,并将密码发布在pma_password
. 或者,如果您使用的是 http auth 模式,您可以创建一个带有用户名和密码的链接,例如http://user:[email protected]/phpmyadmin/...
回答by Arun Kushwaha
Add code in config.inc.php below of /* Authentication type */. It exists in the root folder
在 /* Authentication type */ 下面的 config.inc.php 中添加代码。它存在于根文件夹中
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
回答by absiddiqueLive
Edit config.inc.php
编辑 config.inc.php
Location : /etc/phpmyadmin/config.inc.php
位置:/etc/phpmyadmin/config.inc.php
Find for the blow code
查找打击代码
$cfg['Servers'][$i]['auth_type'] = 'cookie';
And replace the line of code by blow code
并用吹码替换代码行
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['username'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_password';
If your password null or '' the uncomment the blow line
如果您的密码为 null 或 '' 取消注释吹线
//$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
to
到
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
then it will work fine !
然后它会正常工作!
回答by gjerich
config.inc.php
配置文件
/* Authentication type */
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';
}
$_SERVER["REMOTE_ADDR"] == '::1' (ipv6)
$_SERVER["REMOTE_ADDR"] == '127.0.0.1' (ipv4)
$_SERVER["REMOTE_ADDR"] == '::1' ( ipv6)
$_SERVER["REMOTE_ADDR"] == '127.0.0.1' ( ipv4)
回答by MyO
Sometimes when working at your local environment it annoys to login each time. To avoid it you can do the following:
有时在您的本地环境中工作时,每次登录都很烦人。为了避免它,您可以执行以下操作:
Add following lines at bottom of file:
在文件底部添加以下几行:
phpmyadmin\config.inc.php
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';
After that shutdown your db server & restart again. Now check & you will see that you will login without entering user name & password.
之后关闭您的数据库服务器并重新启动。现在检查&您将看到您无需输入用户名和密码即可登录。