【问题标题】:Cannot get access to phpmyadmin无法访问 phpmyadmin
【发布时间】:2016-09-03 12:50:07
【问题描述】:

每次我尝试访问 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

【问题讨论】:

  • 127.0.0.1 和 localhost 对于 mysql.User 表是不同的。所以尝试使用 localhost 而不是 127.0.0.1 作为主机

标签: mysql phpmyadmin


【解决方案1】:

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

还要注意,使用 auth_type = 'http',您根本不需要 $cfg['Servers'][$i]['user']$cfg['Servers'][$i]['password'] 指令;它们仅与 auth_type = 'config' 一起使用。

您是否有可能较早设置密码?许多包管理器在安装过程中要求您输入密码。确保您使用的是 MySQL 根用户的密码,而不是 system 根用户。这可能有点令人困惑,因为它们都被称为 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”作为密码,结果相似。

【讨论】:

    【解决方案2】:

    专业人士建议甚至提倡使用 root 帐户作为数据库的登录名。您应该查看数据库中的GRANTs,类似于

    GRANT SELECT, INSERT ON MyDB.* to MyDBUser@'localhost' IDENTIFIED BY 'MyDBPassword';
    

    【讨论】:

      【解决方案3】:

      在 *nix 系统上获得 root 访问权限的最佳方法,请参阅 here 以获取有关恢复 MySQL root 帐户的说明。

      【讨论】:

        猜你喜欢
        • 2014-12-25
        • 2017-09-05
        • 2014-04-21
        • 2012-01-17
        • 1970-01-01
        • 1970-01-01
        • 2018-03-02
        • 2018-09-30
        • 2011-01-21
        相关资源
        最近更新 更多