Centos 7 上phpMyAdmin无法登录MySQL服务器

2023-12-20

我安装了mysql-community-server-8.0.13-1.el7.x86_64在带有 Nginx 的 Centos 7 上,并添加了 phpMyAdmin 来管理数据库,但我不断收到错误Cannot log in to the MySQL server来自 phpMyAdmin。我已经尝试了以下方法,并且已经挣扎了几天:

  • 更改了位于的一些参数(在 stackoverflow 上建议)/etc/phpMyAdmin/config.inc.php如下所示,但没有运气:

    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['connect_type'] = 'socket';
    $cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock';
    $cfg['Servers'][$i]['user'] = 'root';          
    $cfg['Servers'][$i]['password'] = 'password'; 
    
  • 我已经尝试过 mysql shell,并且可以使用以下命令登录root和其他用户。但是,我不知道为什么它在 phpMyAdmin 上失败。请帮忙并谢谢!


我能够通过执行以下操作解决此问题:(我应该提到这个解决方案适用于 MySQL 8.0.13 和 phpMyAdmin 4.8.4 - 两者都是今天的最新版本)

1-我编辑了config.inc.php使用这些服务器参数(仅):

/*** This is needed for cookie based authentication to encrypt password in 
cookie. Needs to be 32 chars long. */
$cfg['blowfish_secret'] = 'generate_your_blowfish_secret_32_chars'; 

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';

/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;

2- 在 MySQL 终端上

//Create a new user:
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'your_password';

//Grant all privileges:
mysql> GRANT ALL PRIVILEGES ON *.* To 'user'@'localhost' WITH GRANT OPTION;

//Flush all privileges:
mysql> FLUSH PRIVILEGES;

//Change authentication_string with password:
mysql> ALTER USER user IDENTIFIED WITH mysql_native_password BY 
'your_password';

//Login with the new user and password!

这应该允许您登录 phpMyAdmin。我希望这有帮助!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Centos 7 上phpMyAdmin无法登录MySQL服务器 的相关文章

随机推荐