Php 错误1251-无法登录到MySQL服务器
我今天买了一个VPS作为我的新MySQL服务器。我安装了MySQL、Apache、PHP和phpMyAdmin。我将MySQL用户设置为管理员。我可以在命令行上登录用户,但不能在phpMyAdmin中登录。我得到错误1251无法登录到MySQL服务器 问题在于运行CentOS 6、MySQL 8.0.16和Apache 2.2.15的新Linux VPS。在过去6个小时的谷歌搜索中,我尝试了所有我遇到的东西。我将创建一个列表,列出我尝试过的所有东西,因为这样更容易阅读Php 错误1251-无法登录到MySQL服务器,php,mysql,apache,phpmyadmin,centos6,Php,Mysql,Apache,Phpmyadmin,Centos6,我今天买了一个VPS作为我的新MySQL服务器。我安装了MySQL、Apache、PHP和phpMyAdmin。我将MySQL用户设置为管理员。我可以在命令行上登录用户,但不能在phpMyAdmin中登录。我得到错误1251无法登录到MySQL服务器 问题在于运行CentOS 6、MySQL 8.0.16和Apache 2.2.15的新Linux VPS。在过去6个小时的谷歌搜索中,我尝试了所有我遇到的东西。我将创建一个列表,列出我尝试过的所有东西,因为这样更容易阅读 - setting bin
- 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
还有很多事情我现在记不清了
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'] = '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
$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'] = 'cookie'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'admin'; // MySQL user
$cfg['Servers'][$i]['password'] = 'areallygoodpassword'; // MySQL password (only needed
httpd.conf
<IfModule php5_module>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
</IfModule>
LoadModule php5_module modules/libphp5.so
AddType x-httpd-php .php
AddHandler php5-script .php
在尝试了所有这些之后,我没有运气,我仍然得到相同的错误1251无法登录到MySQL服务器。在这一点上,任何帮助都将不胜感激,因为我正变得绝望
编辑:问题是我的用户密码被保存为缓存\u sha2\u密码,而不是mysql\u本地\u密码。见下面的答案
首先,尝试使用命令禁用SELinux
设置强制执行0
通过MySQL提示符使用查询检查用户、主机和密码插件
从mysql.user中选择用户、主机、插件
插件必须设置为mysql\u native\u password,主机应该是localhost。如果不是,您可以通过以下方式更新插件:
更新mysql.user SET plugin='mysql\u native\u password',其中user='admin'
和更新主机:
更新mysql.user SET host='localhost',其中user='admin'您的密码类型是正确的。我最终按照你说的做了,但它只是更改了条目,而不是用它转换我的密码类型,所以我被锁在了数据库之外。我重新安装了操作系统,最后改为使用alter命令:将用户“root”@“localhost”用“password”标识为mysql_native_password;这很有魅力。非常感谢,因为如果没有这篇文章,我就不会被引导到那条轨道上。
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
Order Allow,Deny
Allow from All
</Directory>
bind-address=127.0.0.1