TinyMVC: PDO & UTF-8 Character Set

When setting up the initial model for a TinyMVC project, I got the following error:

Message: Can’t connect to PDO database ‘mysql’. Error: SQLSTATE[HY000] [2019] Can’t initialize character set UTF-8 (path: /usr/share/mysql/charsets/)

After looking in /path/to/tinymvc/sysfiles/plugins/tinymvc_pdo.php I noticed the following on line 95:

    if(empty($config['charset']))
        $config['charset'] = 'UTF-8';

Since nothing appeared wrong, I did a quick Google search and found this bit of information:

Just tried your recommendation on the other server with php 5.3.6 and it worked with utf8 versus utf-8. Just to double check i tried it again with utf-8 and that didn’t work

So, armed with that knowledge, I updated /path/to/tinymvc/sysfiles/plugins/tinymvc_pdo.php to read as:


    if(empty($config['charset'])) {
        $config['charset'] = 'UTF8';
    }

Bingo! After saving the file and refreshing, the error was gone!

Nick

Leave a Reply