Cannot convert DB to utf8mb4

This forum post has been removed

Number of replies: 21
The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Ken Task -
Picture of Particularly helpful Moodlers

Ouch!   May not be the answer, but another poster discovered that if the DB were/had collation set to utf8_unicode_ci it didn't complain.

Haven't tested that myself ... too many other fires to attend to ....

Have to ask these however, ''good webhost" is who?   And you are NOT on a shared host are you?  Yes, utf8mb4 does take up more space.

I take it you found this:

https://docs.moodle.org/33/en/MySQL_full_unicode_support

Just trying to help you along! ;)

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by William Stewart -
Ken already provided the documentation link, but did you try running the command below?


$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci

In reply to William Stewart

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to William Stewart

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Dan Bennett -

> [...] but shouldn't this whole mess be a lot easier?

Yes. But these days that seems to be asking for a lot.


`innodb_large_prefix` is another requirement on top of the `utf8mb4_unicode_ci` requirement that seems to get lost amongst the docs.

You can set this within your `my.cnf` file in /etc/my.cnf (or where ever yours may be!)

innodb_large_prefix = on




Average of ratings: Useful (1)
In reply to Dan Bennett

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Bret Miller -
Picture of Particularly helpful Moodlers

It doesn't require dedicated, but it does require specific database configuration. I have not personally used shared hosting for some time, but according to this post (https://moodle.org/mod/forum/discuss.php?d=346571), 1&1 might support it sufficiently to get the latest Moodle running.

In reply to Bret Miller

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Dan Bennett -

> This upgrade REQUIRES that the database be converted to utf8mb4-unicode-ci 

Wait - *requires*? Last I worked out is it's recommended, but not required... You can still run Moodle 3.3 on utf8_unicode_ci (I have this currently). You get a warning, but you can continue without issue.

Can you show us the error you're getting that is stopping the upgrade from continuing?

Average of ratings: Useful (1)
In reply to Dan Bennett

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes - but that message isn't talking about the encoding it's talking about the character set. The encoding change is absolutely NOT required. 

I suspect it won't be required in the foreseeable future either as there are a lot of potential problems (as you found). Just carry on without the conversion. 

If you are still getting the UTF-8 warning then that's something else entirely. 

In reply to Howard Miller

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You're confused... in the nicest way. 

UTF8 is the required encoding yes. Moodle will not update (or even run) without the database being in UTF8 encoding (or Moodle thinking it is), yes. 

BUT... the utf8mb4 issue (what we started with) is NOT required. 

UTF8 has been required for as long as I can remember, so forget utf8mb4, your issue is something else. The encoding of your database has ceased to be UTF8 *or* utf8mb4 (as either would be perfectly acceptable).  

utf8mb4-unicode-ci (which has also come up) is a collation (the rules for comparing one string to another) and is even less to do with it. 

I'm not sure what you did, but reloading your database from a backup (which I hope you have) might be all you need to do. 

To be clear... you do NOT need to convert a 3.1 database to work with 3.3. If you are getting unicode warnings out of the blue it is nothing to do with the conversion and we must look elsewhere. However,  my guess would be that you tried to do the conversion and something bad has happened. 

In reply to Howard Miller

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Why did you point Moodle to a new database to do the upgrade? Is this a test upgrade? 

The answer to your question is that when you dumped and reloaded the database you changed the encoding to something other than UTF8. 

I can't remember what Moodle does to check the encoding of a database but I'm guessing it'll be something like...

SELECT default_character_set_name FROM information_schema.SCHEMATA  WHERE schema_name = "moodle";

I expect yours will be latin1 or somesuch. 

In reply to Howard Miller

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Cannot convert DB to utf8mb4

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Humor me... run this on your database...

ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

...or whatever collation you are using.

In reply to Howard Miller

Re: Cannot convert DB to utf8mb4

by Ger Tielemans -

For the new moodle 3.3 I get this warning:

The current setup of MySQL or MariaDB is using 'utf8'. This character set does not support four byte characters which include some emoji. Trying to use these characters will result in an error when updating a record, and any information being sent to the database will be lost. Please consider changing your settings to 'utf8mb4'. See the documentation for full details.

...if I Google the answers are more complex then: 

ALTER DATABASE moodle DEFAULT CHARACTER SET utf8_unicode_ci COLLATE utf8mb4_unicode_ci;
So ...is there somewhere an easter-egg script in the Moodle3.3 distribution?