Common Moodle Installation Errors and How to Fix Them

When installing Moodle 2.3, several errors can occur during the installation. Typical Moodle installation errors are caused by database encoding, PHP version, and the database version. The PHP errors thrown are the Use of undefined constant, Database driver, and Database unicode errors. This article will explain what causes these errors and how to fix them.

Error: Use of undefined constant PHP

This error is caused by installing Moodle on a server with an incorrect version of PHP. An example of this error is similar to the following.

Notice: Use of undefined constant DIR - assumed 'DIR'
in /home/user/public_html/lib/dml/moodle_database.php on line 27
Warning: require_once(DIR/database_column_info.php) [function.require-once]:
failed to open stream: No such file or directory in /home/user/public_html/lib/dml/moodle_database.php on line 27
Fatal error: require_once() [function.require]: Failed opening required 'DIR/database_column_info.php'
(include_path='.:/usr/lib/php:/usr/local/lib/php:/home/user/php')
in /home/user/public_html/lib/dml/moodle_database.php on line 27

If you are on a shared business plan, you can have your account moved to a PHP 5.3 server. On VPS or Dedicated servers, the PHP version can be upgraded. In either case, contact support to request the server move or PHP upgrade.

Error: Database driver problem detected

The database driver error is caused by an outdated version of MySQL. The following is copy of the error.

Error: database driver problem detected
The site administrator should verify server configuration
PHP has not been properly configured with the MySQLi extension so
that it can communicate with MySQL. Please check your php.ini file
or recompile PHP. MySQLi extension is not available for PHP 4.

Fixing this error will depend on the type of server you are one. If you are on a Shared business plan, you will need to move to a server that supports MySQL version 5.1 or higher. Systems can move your account to a server that supports this. On a VPS or Dedicated, tech support can upgrade the MySQL version for you by submitting a ticket.

Error: Database unicode character

When installing Moodle on a new database, if the encoding is not set correctly, the following error will occur.

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).

To fix this error, you will need to set the database collation in to utf8_unicode_ci through PhpMyAdmin. The following will explain how to do this.

Changing the database collation in PhpMyAdmin

  1. Login to your cPanel
  2. Navigate to Databases > PhpMyAdmin.
  3. Select the database on the left that was created for the Moodle site.
  4. On the top right click Operations.
  5. On the Collation drop box, select utf8_unicode_ci.
  6. Click Go.

Now when you install Moodle, the error will not appear.

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

2 thoughts on “Common Moodle Installation Errors and How to Fix Them

  1. Sort of helpful. Doesn’t explain why I’m told by softalicious that I can update things but then I can’t because I don’t have the “sodium” PHP extension.

Was this article helpful? Join the conversation!