我今天买了一个 VPS 作为我的新 MySQL 服务器。我安装了 MySQL、Apache、PHP 和 phpMyAdmin。我将我的 MySQL 用户设置为“admin”。我可以在命令行上登录用户,但不能在 phpMyAdmin 中登录。我收到错误#1251 Cannot log in to the MySQL server。
问题出在运行 CentOS 6、MySQL 8.0.16 和 Apache 2.2.15 的新 Linux VPS 上。在过去 6 个小时的谷歌搜索中,我已经尝试了我遇到的一切。我将创建一个我尝试过的所有内容的列表,因为这样会更容易阅读。
- setting bind-address to 127.0.0.1
- putting my username and password into config.inc.php
- setting the host to 127.0.0.1 in config.inc.php
- trying sockets over TCP (and setting the host to localhost when using sockets)
- creating a soft-link shortcut from `/usr/share/phpmyadmin` to `/var/www/html/phpmyadmin`
- reinstalling and running mysql_secure_installation
还有很多我一时想不起来的事情。
配置文件
$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'] = 'mysqli'; // 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]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
我的.cnf
bind-address=127.0.0.1
在尝试了所有这些之后,我没有运气,我仍然遇到同样的错误#1251 Cannot log in to the MySQL server。在这一点上,任何帮助将不胜感激,因为我越来越绝望。
编辑:问题是我用户的密码被保存为 caching_sha2_password 而不是 mysql_native_password。请参阅下面的答案。
一只斗牛犬