问题 - phpMyAdmin 的 HTTP 错误 500。Apache
错误日志
[Wed Aug 19 02:52:11.063688 2020] [:error] [pid 94653] [client ::1:56202] PHP Warning: Unsupported declare 'strict_types' in /usr/share/php/PhpMyAdmin/MoTranslator/Loader.php on line 23
[Wed Aug 19 02:52:11.063864 2020] [:error] [pid 94653] [client ::1:56202] PHP Parse error: syntax error, unexpected '?' in /usr/share/php/PhpMyAdmin/MoTranslator/Loader.php on line 116
切换到 php7.4 后 phpMyAdmin 完全正常工作。此问题仅发生在 php5.6 上
设置 - Ubuntu 20.04、php5.6、Apache/2.4.41、phpMyAdmin-4.9.5deb2、mysql-8.0.21 php -m(输出)
[PHP Modules]
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
我已经从发行版中删除了 phpmyadmin,并通过 zip 进行了安装。我收到以下错误。
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
我发现问题在于身份验证方法,并将“caching_sha2_password”更改为“mysql_native_password”,但仍然出现上述错误。
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| debian-sys-maint | $A$005$@0IC@&1C
O:Xf94qofd9PGZM4cSAB0xP0ZsNz7GUaX8UuPiAYIj5M0 | caching_sha2_password | localhost |
| mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| phpmyadmin | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | mysql_native_password | localhost |
| root | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | mysql_native_password | localhost |
| surendhar | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | mysql_native_password | localhost |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
7 rows in set (0.00 sec)
答案1
问题 - ubuntu 20.04 使用 mysql v8 并使用 caching_sha2_password。php7.4 一切正常。但是当您使用 php5.6 时,您会收到两个错误
- 服务器发送了客户端未知的字符集
- 服务器请求的身份验证方法对于客户端来说未知
为了解决这个问题,我们需要将以下代码添加到 /etc/mysql/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
default-authentication-plugin=mysql_native_password
您还需要通过 mysql 中的以下代码更新用户身份验证方法
alter user 'username'@'localhost' identified with mysql_native_password by 'password';
答案2
如果您说在 20.04 phpmyadmin 软件包中将其与 php5.6 一起使用,则它会稍微混乱。它提供 PMA4.9.5,与 php5.5+ 兼容,但它依赖于 php-phpmyadmin-motranslator >= 5.0,与 php7.1+ 兼容。您在日志中看到的致命错误是由于代码中使用了空合并运算符 ??,这是 php7 功能。
PMA 并不是您严重依赖发行版打包的东西。只需从 github 下载 4.9.5 zip,将其解压到您的 webroot 下的某个位置,它就可以正常工作。