Installation fails (Moodle 3.2.2)

I'm quite new to Moodle and trying to install H5P on there but getting errors. Could someone a bit more knowledgable have a look and give some hints as to where it's going wrong?

I've attached the error output.

Many thanks,


thomasmars's picture

Hi, this is a product of your database character settings and a rather large index on our part in the following table definition:

CREATE TABLE mood_hvp_libraries (
id BIGINT(10) NOT NULL auto_increment,
machine_name VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
title VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
major_version SMALLINT(4) NOT NULL,
minor_version SMALLINT(4) NOT NULL,
patch_version SMALLINT(4) NOT NULL,
runnable TINYINT(1) NOT NULL,
embed_types VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
preloaded_js LONGTEXT COLLATE utf8mb4_unicode_ci,
preloaded_css LONGTEXT COLLATE utf8mb4_unicode_ci,
drop_library_css LONGTEXT COLLATE utf8mb4_unicode_ci,
semantics LONGTEXT COLLATE utf8mb4_unicode_ci NOT NULL,
tutorial_url VARCHAR(1000) COLLATE utf8mb4_unicode_ci,
, KEY mood_hvplibr_macmajminpatru_ix (machine_name, major_version, minor_version, patch_version, runnable)
DEFAULT COLLATE = utf8mb4_unicode_ci ROW_FORMAT=Dynamic
COMMENT='Stores information about libraries.'


The given key in this definition is 268bytes, however your error message says that it exceeds 767bytes. The problem arises when the character setting is utf8, then the max number of bytes turns to 255bytes, you can read more about it here.

Anyway, the quickest fix for you would be to add the "Innodb_large_prefix" to your database settings, and we will look into what can be done to improve the size of the index on the plugin end. I have created an issue for it at the H5P public issue tracker.

Could you provide some more info on which database you're using and with what settings ?

Thanks for the report,

- Thomas

Thanks for the guidance, got it fixed now.

My database was a mySQL, using innodb (anaconda?). I performed an update to baracuda using the moodle instructions, then edited the my.cnf file to add the setting above. The only other issue I kept getting was that upon a failed installation, it left behind the old mood_hvp table which then needed to be manually dropped.

(If I sound like I know what I'm talking about, I'm winging it... this is my first time setting up databases and the like. It's a major learning curve!)

This is a tricky one ;-)  From Moodle 3.1.5 and 3.2.2 onwards, the MySQL database in new installations will add the large_prefix option and use the "better" utf8mb4_unicode_ci" collation (4 bytes per character, allowing emojis). For existing installations, the recommendation will be to upgrade the database. However, the H5P plugin should also work on Moodle installations who choose not to upgrade their database. This would mean either shortening column machine_name to 191 characters (191 x 4 = 764 < 767 characters, which is the default maximum length), or using a prefix for this column in the key definition.

thomasmars's picture

Thank you for your insight, it is very valuable. I guess this should work for most people who follow the recommendations for Moodle databases, but we'll make sure to support those who choose not to, it will be addressed in the public issue tracker, and we'll make sure to pay closer attention to this restraint in following releases.

Thanks again.

(I was just starting to correct my post when I received your answer !) As you said, people following Moodle recommendations should be fine :

  • if you have an older Moodle installation with utf8_unicode_ci collation (3 bytes per character), column machine_name fits under the 767 bytes limit (255 x 3 = 765).
  • if you have a new installation, or have upgraded your database, then the DB uses utf8mb4_unicode_ci (4 bytes per character), and also has the large_prefix setting. Again, machine_name fits under the larger 3072 bytes limit (255 x 4 = 1020).

But problems may arise for people using utf8mb4_unicode_ci without the large_prefix option (as was the case above). And it would be good if the H5P plugin would check this.