我用Nginx在Centos 7上安装了mysql-community-server-8.0.13-1.el7.x86_64,并添加了phpMyAdmin来管理数据库,但我一直从phpMyAdmin获得错误Cannot log in to the MySQL server。我已经尝试了以下几天并一直在挣扎:
/etc/phpMyAdmin/config.inc.php上的一些参数(在堆栈溢出中建议使用),如下所示,但没有运气:
$cfg‘’Servers‘’host‘= 'localhost';$cfg’‘Servers’connect_type‘= 'socket';$cfg’‘Servers’socket‘=’var/lib/mysql/mysql.sock‘;$cfg’‘Servers’‘user’= 'root';$cfg‘’Servers‘密码’=‘密码’;root和其他用户登录。但是,我不知道为什么它在phpMyAdmin上失败了。请帮帮忙,谢谢!发布于 2019-01-10 20:00:31
我能够通过以下操作来解决这个问题:(我应该指出,这个解决方案适用于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。我希望这能帮上忙!
发布于 2020-07-08 15:47:00
这是我的工作:
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourNewPassword';发布于 2022-01-05 05:44:38
在CentOS 7上,我不得不:
上面雅克曼所接受的答案上的一个小改动。我试过所有其他的方法,但没有使用“WITH mysql_native_password”子句。
https://stackoverflow.com/questions/54030283
复制相似问题