gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 00:25:05 25 4
gpt4 key购买 nike

我在带有 Nginx 的 Centos 7 上安装了 mysql-community-server-8.0.13-1.el7.x86_64,并添加了 phpMyAdmin 来管理数据库,但我一直收到错误 Cannot从 phpMyAdmin 登录到 MySQL 服务器。我尝试了以下方法,现在已经苦苦挣扎了几天:

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

    $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。希望对您有所帮助!

关于nginx - Centos 7上phpMyAdmin无法登录MySQL服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54030283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com