In MySQL I have created the user in this webpage query using the query:
CREATE USER '[user]'@'[host]' IDENTIFIED WITH caching_sha2_password BY '[password]';
and granted this user the only permissions it needs:
grant insert, select on [db].[table] to '[user]'@'[host]';
I specifically don’t use mysql_native_password
since it is disabled by default in MySQL 8.4 and removed in MySQL 9.0.
php 8.4 – Choosing a library reads, in part:
// Recommended, compiles with mysqlnd
$ ./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
// Alternatively recommended, compiles with mysqlnd
$ ./configure --with-mysqli --with-pdo-mysql
// Not recommended, compiles with libmysqlclient
$ ./configure --with-mysqli=/path/to/mysql_config --with-pdo-mysql=/path/to/mysql_config
while MySQL 8.4 – 8.4.1.2 Caching SHA-2 Pluggable Authentication reads, in part:
**Installing SHA-2 Pluggable Authentication**
The caching_sha2_password plugin exists in server and client forms:
- The server-side plugin is built into the server, need not be loaded
explicitly, and cannot be disabled by unloading it.
- The client-side plugin is built into the libmysqlclient client
library and is available to any program linked against libmysqlclient.
The server-side plugin uses the sha2_cache_cleaner audit plugin as a helper to perform password cache management.
sha2_cache_cleaner, like caching_sha2_password, is built in and need not be installed.
I am currently compiling PHP 8.4 with:
./configure
--prefix=$path_to_php_bin
--with-apxs=/usr/local/apache2/bin/apxs
--enable-mbstring
--with-mysqli
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-iconv=$(brew --prefix libiconv)
--enable-fpm
but when I attempt to create a mysqli link
on a webpage, I generate a Fatal error:
Fatal error: Uncaught mysqli_sql_exception: The server requested authentication method unknown to the client [caching_sha2_password] in [path_to_global_php_commands_include_file]:201
#0 [path_to_global_php_commands_include_file](201): mysqli_connect([host], [user], [password], [db])
#1 [path_to_mysqli_connect_variables_file](10): connectDBi([host], [user], [password], [db])
#2 [path_to_php/html_header_file](12):include('[path_to_mysqli_connect_variables_file]')
#3 [path_to_website_index_file](3): include('[path_to_php/html_header_file]')
#4 {main} thrown in [path_to_global_php_include_commands_file] on line 201
I take it that this Fatal error is being generated because I’m not compiling PHP 8.4 with libmysqlclient
because Choosing a library – php 8.4 recommends against doing so while MySQL 8.4 – 8.4.1.2 Caching SHA-2 Pluggable Authentication says it is necessary to do so.
If it is necessary to compile PHP 8.* with libmysqlclient
in order to use caching_sha2_password
, with MySQL 8.*:
-
Why does PHP recommend against doing so?
-
Is there a better way to enable
caching_sha2_password
than
compiling PHP 8.* withlibmysqlclient
? -
If I do have to compile PHP 8.* with
libmysqlclient
using:
$ ./configure --with-mysqli=/path/to/mysql_config --with-pdo-mysql=/path/to/mysql_config
is there code that needs to be in my.conf
in order to compile PHP 8.* effectively for [caching_sha2_password]
use?
- In
--with-mysqli=
… and--with-pdo-mysql=
…,mysql_config
meansmy.conf
, right?
Thanks in advance!