Unable to add new users

Unable to add new users

by Fergal McCann -
Number of replies: 3

Hi All,

I was being prompted by Moodle to update my Collation of my database from utf8_bin to utf8mb4_bin. Since having done this I am unable to add new users to my moodle site and I get the following error when trying to add users. (see image attached)

https://moodle.org/pluginfile.php/143/mod_forum/post/1706821/Screenshot%202021-06-21%20at%2013.53.02.png

Any advice, would be greatly appreciated. 

Average of ratings: -
In reply to Fergal McCann

Re: Unable to add new users

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

…update my Collation of my database from utf8_bin to utf8mb4_bin. Since having done this… – what steps did you take?

It looks like your database uses character set utf8 but in config.php you have 'dbcollation' => 'utf8mb4_bin' which isn't a valid collation for that character set. But neither utf8_bin nor utf8mb4_bin are the correct collation for Moodle, it should be either:

  1. utf8mb4_unicode_ci if the database uses the recommended utf8mb4 character set, or
  2. utf8_unicode_ci if it uses the utf8 character set.

This reply suggests how to migrate to the recommended character set utf8mb4 and collation utf8mb4_unicode_ci (based on these docs).

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Unable to add new users

by Fergal McCann -
Thanks Leon,

I have switched it back to utf8 and it's working again.

I had changed it to utf8mb4_unicode_ci in the config.php, but selected the wrong character set in phpMyAdmin. I changed it to match utf8mb4_unicode_ci that was set in the config.php but I was still unable to get it working so I just reverted back to utf8.
In reply to Fergal McCann

Re: Unable to add new users

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

If you want to migrate to utf8mb4, which is recommended, you'll need to follow the four steps in that link: 1) check the database configuration, 2) make any needed database configuration changes, 3) run Moodle's mysql_collation.php script, and 4) change 'dbcollation' in config.php.

If you try this and there are problems, you can post in the forums and we'll try to help.

Average of ratings: Useful (1)