无法访问 phpmyadmin
Cannot get access to phpmyadmin
每次我尝试访问 phpMyAdmin 时,它都会弹出一个对话框,要求提供用户名和密码。我尝试使用 root 作为用户名并将密码留空,但它不起作用。但是,当我尝试使用 admin 作为用户名并将密码留空时,它起作用了。但是还有一个问题,就是admin没有创建数据库的权限。
那么我怎样才能以 root 身份访问 phpmyadmin?或者我如何在以管理员身份登录时提升权限?
以下为config.inc.php:
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname
专业人士不推荐甚至提倡使用root帐户作为数据库的登录名。您应该查看数据库中的 GRANTs,类似于
GRANT SELECT, INSERT ON MyDB.* to MyDBUser@'localhost' IDENTIFIED BY 'MyDBPassword';
在 *nix 系统上获得 root 访问权限的最佳方法参见 here 恢复 MySQL root 帐户的说明。
尝试从命令行客户端登录。您说您正在尝试使用空白密码,但我没有看到使用空白密码登录所需的配置指令 $cfg['Servers'][$i]['AllowNoPassword'] = true;
。
另请注意,使用 auth_type = 'http',您根本不需要 $cfg['Servers'][$i]['user']
或 $cfg['Servers'][$i]['password']
指令;它们仅用于 auth_type = 'config'.
你有没有机会提前设置密码?许多包管理器在安装过程中要求您输入密码。确保您使用的是 MySQL root 用户的密码,而不是 system root 用户。这可能有点令人困惑,因为它们都被称为 root。
尝试从命令行客户端登录; mysql -u root -p
之类的东西应该很接近。
在 MySQL 中,主机字段 %
与 localhost
不同,因此由于您是通过 TCP/IP 网络连接到 127.0.0.1,因此您的帐户're authentication against 是 '127.0.0.1' 或 '%' 作为主机的那个,而不是 'localhost' -- 尽管您可以尝试通过套接字连接以查看是否改变了一些事情。将 $cfg['Servers'][$i]['connect_type'] = 'tcp';
行更改为 $cfg['Servers'][$i]['connect_type'] = 'socket';
and/or 在命令行中使用 mysql --protocol=socket -u root -p
来尝试这个不同的帐户;如果可行,您可以在不诉诸暴力的情况下修复其他用户的密码。
如果您仍然无法连接,则必须 reset the MySQL root password。
"admin" 用户帐户有效但没有任何权限的原因是您启用了匿名用户,并且您正在以 anonymous/non-existent 用户身份连接。这样的用户通常能够连接,但之后什么也做不了。您可以将 "kitchen" 作为用户名,将 "table" 作为密码,结果相似。
每次我尝试访问 phpMyAdmin 时,它都会弹出一个对话框,要求提供用户名和密码。我尝试使用 root 作为用户名并将密码留空,但它不起作用。但是,当我尝试使用 admin 作为用户名并将密码留空时,它起作用了。但是还有一个问题,就是admin没有创建数据库的权限。
那么我怎样才能以 root 身份访问 phpmyadmin?或者我如何在以管理员身份登录时提升权限?
以下为config.inc.php:
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname
专业人士不推荐甚至提倡使用root帐户作为数据库的登录名。您应该查看数据库中的 GRANTs,类似于
GRANT SELECT, INSERT ON MyDB.* to MyDBUser@'localhost' IDENTIFIED BY 'MyDBPassword';
在 *nix 系统上获得 root 访问权限的最佳方法参见 here 恢复 MySQL root 帐户的说明。
尝试从命令行客户端登录。您说您正在尝试使用空白密码,但我没有看到使用空白密码登录所需的配置指令 $cfg['Servers'][$i]['AllowNoPassword'] = true;
。
另请注意,使用 auth_type = 'http',您根本不需要 $cfg['Servers'][$i]['user']
或 $cfg['Servers'][$i]['password']
指令;它们仅用于 auth_type = 'config'.
你有没有机会提前设置密码?许多包管理器在安装过程中要求您输入密码。确保您使用的是 MySQL root 用户的密码,而不是 system root 用户。这可能有点令人困惑,因为它们都被称为 root。
尝试从命令行客户端登录; mysql -u root -p
之类的东西应该很接近。
在 MySQL 中,主机字段 %
与 localhost
不同,因此由于您是通过 TCP/IP 网络连接到 127.0.0.1,因此您的帐户're authentication against 是 '127.0.0.1' 或 '%' 作为主机的那个,而不是 'localhost' -- 尽管您可以尝试通过套接字连接以查看是否改变了一些事情。将 $cfg['Servers'][$i]['connect_type'] = 'tcp';
行更改为 $cfg['Servers'][$i]['connect_type'] = 'socket';
and/or 在命令行中使用 mysql --protocol=socket -u root -p
来尝试这个不同的帐户;如果可行,您可以在不诉诸暴力的情况下修复其他用户的密码。
如果您仍然无法连接,则必须 reset the MySQL root password。
"admin" 用户帐户有效但没有任何权限的原因是您启用了匿名用户,并且您正在以 anonymous/non-existent 用户身份连接。这样的用户通常能够连接,但之后什么也做不了。您可以将 "kitchen" 作为用户名,将 "table" 作为密码,结果相似。