Post-install fixes for Moodle: UTF-8 support

Print Friendly, PDF & Email

After installing Moodle, I went to the main URL and it automatically ran some checks, the first of which failed.  The message in horrible (or at least, noticeable) red, is this:

It is required that you store all your data in Unicode format (UTF-8). New installations must be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).

Ah, we created the database using our default MySQL useradd script, which creates a database in the default way.  Easily fixed:

mysql> show create database moodle_db;
+-----------+----------------------------------------------------------------------+
| Database  | Create Database                                                      |
+-----------+----------------------------------------------------------------------+
| moodle_db | CREATE DATABASE `moodle_db` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+-----------+----------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> drop database moodle_db;
Query OK, 0 rows affected (0.11 sec)

mysql> create database moodle_db character set 'utf8';
Query OK, 1 row affected (0.01 sec)

mysql> show create database moodle_db;
+-----------+--------------------------------------------------------------------+
| Database  | Create Database                                                    |
+-----------+--------------------------------------------------------------------+
| moodle_db | CREATE DATABASE `moodle_db` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+-----------+--------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> use moodle_db;
Database changed
mysql> show variables like "collation";
Empty set (0.01 sec)

mysql> show variables like "collation_database";
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| collation_database | utf8_general_ci |
+--------------------+-----------------+
1 row in set (0.00 sec)

mysql>

That did the trick!

Hopefully, the general collation will work for Moodle.

Darn it.  I just read here: http://docs.moodle.org/24/en/admin/environment/unicode that

Moodle tables are normally set-up using the utf8_unicode_ci collation.

So, I did the following:

mysql> drop database moodle_db;
Query OK, 0 rows affected (0.00 sec)

mysql> create database moodle_db character set 'utf8' collate 'utf8_unicode_ci';
Query OK, 1 row affected (0.00 sec)

mysql> use moodle_db;
Database changed
mysql> show variables like "collation_database";
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| collation_database | utf8_unicode_ci |
+--------------------+-----------------+
1 row in set (0.00 sec)

mysql>

Done!

 

 

 

About CS SysAdmins

The CS Department System Administrators
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *