Converting Database encoding with minus("-") in Database does not work

Converting Database encoding with minus("-") in Database does not work

by Sven Nissel -
Number of replies: 2

Moodle Version: 3.7.5
mariadb: 10.1.44
System: Ubuntu 18.04

I try to convert database encoding from utf8 to utf8mb4 with this manual: https://docs.moodle.org/37/en/MySQL_full_unicode_support

With one Installation no problem with the other I get an error:

/opt/plesk/php/7.3/bin/php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci
Converting database to 'utf8mb4_unicode_ci' for https://carestream.lernyx.com:
Error: Tried to alter the database with no success. Please try manually changing the database
                    to the new collation and character set and then run this script again.

I have take a look on the code:

https://github.com/moodle/moodle/blob/master/admin/cli/mysql_collation.php#L122

If i change

$sql = "ALTER DATABASE $CFG->dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE = $collation";

to

$sql = "ALTER DATABASE `$CFG->dbname` DEFAULT CHARACTER SET $charset DEFAULT COLLATE = $collation";

Now it works.

Can somebody of moodle team fix this?




Average of ratings: -
In reply to Sven Nissel

Re: Converting Database encoding with minus("-") in Database does not work

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Sven,
would you mind to file your issue into the Tracker?

Otherwise, I'll do it (almost) on behalf of you.

HTH,
Matteo