mysql - 无法访问 phpmyadmin

标签 mysql 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

最佳答案

尝试从命令行客户端登录。您说您尝试使用空白密码,但我没有看到配置指令 $cfg['Servers'][$i]['AllowNoPassword'] = true;这是使用空白密码登录所必需的。

另请注意,使用 auth_type = 'http' 时,您不需要 $cfg['Servers'][$i]['user']$cfg['服务器'][$i]['password']指令;它们仅与 auth_type = 'config' 一起使用。

您是否有可能提前设置密码?许多包管理器在安装过程中要求您输入密码。确保您使用的是 MySQL root 用户的密码,而不是系统 root 用户的密码。这可能有点令人困惑,因为它们都称为 root。

尝试从命令行客户端登录;像 mysql -u root -p 这样的东西应该很接近。

在 MySQL 中,主机字段 %localhost 不同,因此,由于您通过 TCP/IP 网络连接到 127.0.0.1,因此您使用的帐户身份验证是使用“127.0.0.1”或“%”作为主机,而不是“localhost”——尽管您可以尝试通过套接字连接以查看是否会发生变化。将 $cfg['Servers'][$i]['connect_type'] = 'tcp'; 行更改为 $cfg['Servers'][$i]['connect_type' ] = 'socket'; 和/或在命令行使用 mysql --protocol=socket -u root -p 来尝试这个不同的帐户;如果有效,您可以修复其他用户的密码,而无需诉诸暴力。

如果您仍然无法连接,则必须reset the MySQL root password .

“管理员”用户帐户可以工作但没有任何权限的原因是您启用了匿名用户,并且您正在以匿名/不存在的用户身份进行连接。此类用户通常能够连接,但此后不会真正执行任何操作。您可以将“kitchen”作为用户名,将“table”作为密码,得到类似的结果。

关于mysql - 无法访问 phpmyadmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37106392/

相关文章:

php - MYSQL选择并限制数量 'group by'

php - 插入 SQL 查询未成功执行

php - 登录 phpMyAdmin 时出现错误 2002

更新时在同一张表上触发 MySQL

mysql - 这个MySQL连接查询可以优化吗?

php - 有什么原因导致我的 php 脚本中的查询不起作用吗?

mysql - 如何使用 knex/Bookshelf 选择数据库表达式作为值

mysql - phpmyadmin 需要一个符号名称! (位置 312 处 ")"附近)

apache - 如何远程访问phpmyadmin

php - 为什么 phpMyAdmin 没有导入我的表?