Connecting to MySQL Cluster from PHP 5.6

Posted January 21, 2021 1.1k views
MySQLPHPDigitalOcean Managed MySQL DatabaseNeeds Product Answer


For #reasons I have a PHP5.6 codebase I wish to deploy on a DO Droplet, connecting to a MySQL Cluster.

Obviously - PHP5.6 is bad and wrong and really we should upgrade to 7.3 or higher. However - we are caught on the hop and need a tactical solution to buy the time to finish the PHP8 compatibility work.

When attempting to connect with the following sample code:

    $conn = mysqli_init();

    if(!$conn) {
        die('init failed');

    mysqli_options($conn, MYSQLI_SET_CHARSET_NAME, 'utf8');

    $res = mysqli_real_connect($conn, 'dbclusteraddress:port',
    'username', 'password', 'dbname');

We get the connect_error 2054 with the description Server sent charset unknown to the client. Please, report to the developers

Beleive this is because the server will be sending back utf8mb4 which is the MySQL Default and not understood by PHP 5.6 MySQLi.

Is there a way we can change the PHP5.6 code/configuration to support/handle the utf8mb4 or a way to change the start up configuration of the server, i.e. this:


I can’t see that we have any access to the server (for obvious reasons) or any way we can set that value through the control panel.


edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


In other to connect to the database, for clients/Users that support the “mysqlnativepassword” authentication such as some PHP apps

You will need to run the below “ alter command ” The below command can be used to change the authentication for the user after creation as well

ALTER USER myuser IDENTIFIED WITH mysqlnativepassword BY ‘mypassword’;

Below is a link that provides for more information on

You can change the authentication method by navigating to database cluster in cloud console and click on Users & Databases tab. After which you can click on More button and select Edit encryption method.

Please note:- Changing the password encryption method will change the password of user.

Hope this helps!

Sri Charan

by Mark Drake
If you're new to working with managed databases, the best way to perform certain tasks, like connecting to the database, may not be self-evident. In this guide, we will go over how to install client programs for a variety of database management systems, including PostgreSQL, MySQL, and Redis, on an Ubuntu 18.04 server. We'll also explain how to use these programs to connect to a managed database instance.