Our thinking


Problems with php 5.6 on Ubuntu 20.04

I’m putting this here as I will probably need to refer to it again in the future. We’ve taken over the development for a web app that uses php 5.6 and I’m trying to get it working with MySQL 8 on Ubuntu 20.04. Easier said than done.

The issue – Ubuntu 20.04 uses MySQL v8 which uses a modern authentication method of sockets or a caching_sha2_password. Everything works fine with php 7.4. When php is downgraded to 5.6, we get two errors

Server sent charset unknown to the client

The server requested authentication method unknown to the client

Fortunately it’s straightforward to fix both of these errors without having to downgrade MySQL by editing the my.cnf file. In my Ubuntu 20.04 install, this was in /etc/mysql/mysql.conf.d/mysql.cnf

Fortunately it’s straightforward to fix both of these errors without having to downgrade MySQL by editing the my.cnf file. In my Ubuntu 20.04 install, this was in /etc/mysql/mysql.conf.d/mysql.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

After this has been done, you next need to reset the password for the MySQL root user via:

alter user 'root'@'localhost' identified with mysql_native_password by 'password';

(where password is replaced by the password you want to use)

In my testing, I also had to restart the MySQL and Apache services for it to all work.

Leave a Reply