cloudpanel-io / cloudpanel-ce

1.21k stars 99 forks source link

mysql_native_password is deprecated and needs to be replaced with caching_sha2_password #423

Closed jamiolee closed 5 months ago

jamiolee commented 7 months ago

CloudPanel version(s) affected

2.4.0

Description

All MySQL accounts created by CloudPanel are using mysql_native_password by default, and it's causing the MySQL error log at "/var/log/mysql/error.log" to generate a new a log line every time anyone hits the (WordPress/PHP) website.

Example log line: 2024-02-06T22:14:02.000394Z 134 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

This is only a warning message so it's not crucial but it does quickly fill up the MySQL error log file on heavy traffic websites making debugging MySQL errors problematic. As mysql_native_password are now deprecated, they should be replaced with caching_sha2_password.

How to reproduce

Create a new site, either PHP or WordPress, then create a MySQL database. Visit the website and check the logs at "/var/log/mysql/error.log". Refresh the website and notice that the log populates a new entry with the warning for every page visit.

Possible Solution

Replace "mysql_native_password" with "caching_sha2_password" for all accounts created by CloudPanel.

Additional Context

I have tried updating the mysql user for the website to use "caching_sha2_password" instead but after running FLUSH PRIVILEGES; and then systemctl restart mysql the error logs lines are still getting generated. So I am unsure what user in CloudPanel is causing this issue, possibly the mysql root?

ghost commented 7 months ago

Please note that wordPress relies on mysql_native_pasword and not caching_sha2_passsword https://core.trac.wordpress.org/ticket/52496

WordPress basically only supports plain text password passing to the database and it was a pain when MySQL 10 was released and socket based was default with fallback to encrypted passwords.