SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers Magento2.1.9

I am getting Server sent charset unknown error during setting up magento 2.1.9 on localhost.

PHP version – 5.6 or 7.1,
MySQL version – 8.0

I tried to add in my.cnf

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

but it is not working.

Is there any other fix for the issue?