FYI, I looked into my CentOS 8 dev server, and apparently, it worked with caching_sha2_password
MySQL 8 server. However, I got PHP version 7.4.12:
php -v
So I have:
PHP 7.4.12 (cli) (built: Oct 27 2020 15:01:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies
You need auth_plugin_sha256_password
support in your PHP mysqlnd (from my phpinfo() output) :
You can also verify that from the Linux CLI itself:
php -i | grep mysqlnd
And will see the following on CentOS 8 Linux server:
/etc/php.d/20-mysqlnd.ini,
Client API library version => mysqlnd 7.4.12
mysqlnd
mysqlnd => enabled
Version => mysqlnd 7.4.12
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_caching_sha2_password,auth_plugin_sha256_password
Client API version => mysqlnd 7.4.12
Here is what we see on OpenSUSE 15.2 Linux server:
Client API library version => mysqlnd 7.4.6
mysqlnd
mysqlnd => enabled
Version => mysqlnd 7.4.6
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_caching_sha2_password,auth_plugin_sha256_password
Client API version => mysqlnd 7.4.6
My best guess is OpenSUSE plugin has issues.
TL;DR
- At least use PHP version 7.4.12.
- PHP mysqlnd must have support for
auth_plugin_caching_sha2_password
plugin.
- If everything failed, set MySQL 8 password auth type to
mysql_native_password
by running the following query as root user (mysql -u root -h hostname -p mysql
):
ALTER USER user@host IDENTIFIED WITH mysql_native_password BY 'password';
- Always check PHP docs