我今天買了一個(gè) VPS 作為我的新 MySQL 服務(wù)器。我安裝了 MySQL、Apache、PHP 和 phpMyAdmin。我將我的 MySQL 用戶設(shè)置為“admin”。我可以在命令行上登錄用戶,但不能在 phpMyAdmin 中登錄。我收到錯(cuò)誤#1251 Cannot log in to the MySQL server。問題出在運(yùn)行 CentOS 6、MySQL 8.0.16 和 Apache 2.2.15 的新 Linux VPS 上。在過去 6 個(gè)小時(shí)的谷歌搜索中,我已經(jīng)嘗試了我遇到的一切。我將創(chuàng)建一個(gè)我嘗試過的所有內(nèi)容的列表,因?yàn)檫@樣會(huì)更容易閱讀。- 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還有很多我一時(shí)想不起來的事情。配置文件$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我的.cnfbind-address=127.0.0.1在嘗試了所有這些之后,我沒有運(yùn)氣,我仍然遇到同樣的錯(cuò)誤#1251 Cannot log in to the MySQL server。在這一點(diǎn)上,任何幫助將不勝感激,因?yàn)槲以絹碓浇^望。編輯:問題是我用戶的密碼被保存為 caching_sha2_password 而不是 mysql_native_password。請參閱下面的答案。
1 回答

一只斗牛犬
TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊
首先,嘗試使用以下命令禁用 SELinux
setenforce 0
通過 MySQL 提示使用查詢來檢查用戶、主機(jī)和密碼插件。
SELECT user, host, plugin from mysql.user
插件必須設(shè)置為“mysql_native_password,主機(jī)應(yīng)該是本地主機(jī)。如果不是,你可以通過以下方式更新你的插件: UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'admin'
并更新主機(jī):
UPDATE mysql.user SET host = 'localhost' WHERE User = 'admin'
- 1 回答
- 0 關(guān)注
- 240 瀏覽
添加回答
舉報(bào)
0/150
提交
取消