Moodle "error reading database" in import

Asked by:
Joe_Shiki / 59 Points
2013-09-17 7:44 am EST
I installed moodle in a subdomain, but it seems to be having a lot of problems. When I try to upload the courses that I saved from my old moodle site, I get "error reading database". I also get the same error sometimes when I try to access the page. It also happens at other times when I am setting up the site.

I read the moodle documentation about this at
but there is nothing there that helps me.

I really need to get this fixed so that my students can use it.
Any ideas, anybody?

Thanks a lot.

To ask this user for more information, please first login.

To submit an answer, please login.



7,075 Points
2013-09-17 9:17 am EST
Hello Joe_Shiki,

Thank you for your question. We are happy to help, but will need more information to help troubleshoot the issue, since "error reading database" is a very general error.

Is there any additional information with the error, such as an error code? Can you provide the error?

What steps are you taking to import the classes? This will help us replicate the error.

Have you read the official moodle guide on importing your data, or migrating your site?

We also have a helpful tutorial on moving your website to us, if you are migrating a whole website.

If you have any further questions, feel free to post them below.
Thank you,


To submit a comment on this answer, please first login.

Hi John,

There is no error code. It only says "error reading database" or "error reading from database".

Yes, I have read the Moodle documentation on importing classes and migrating.

I changed the primary domain on my account and wanted to move my moodle from a subfolder of my old primary domain to a sub domain of my new primary domain . However, the whole migration in moodle dscribed on the site is extremely complicated and did not seem like something I could do. Instead, I backed up the classes to my home computer. I then erased the moodle installation with Softaculous.
Then, I made a subdomain, and installed moodle again there.

I always get the error when I try to import classes. It also happens sometimes when I try to log in to the site, sometimes. It also happens sometimes when I try to change settings in site administration.

I have a backup, so should I just uninstall it and try to install it again?
59 Points

2013-09-17 5:42 pm EST
I managed to import the courses, but the problem is still happening. Sometimes, also the site hangs for 2-3 minutes then I get the "database error" . This makes it hard to actually use for students.

Help?? Is anyone from support actually reading these?
59 Points

2013-09-18 6:07 pm EST
Hello Joe_Shiki,

I'm sorry you're having problems with your Moodle installation. And apologies if you think that no one is looking at your problem. We do view ALL of the comments, and it may take a little time to research an issue before you see an answer depending on the problem.

You mentioned that you wanted to move your Moodle installation to a subfolder, but you didn't follow the migration path and instead made a backup of the site and saved it on your local computer. You then proceeded to re-install Moodle to the location wanted to use. The problem here is that the migration procedure probably avoids the issues that you're seeing. Based on this alone, the errors in import may be occurring due to path issues. Did you make a backup of the old Moodle database? Also, do you know if you were using an older version of Moodle compared to the one that you have just installed? We need some version information.

One of the options that may help identify the problem is to turn on the debugging mode in Moodle - check out this article on from the Moodle forums: Error in import course-elements.

Apologies again for not being able to provide a solid answer at this point, but we need more information in order to proceed with troubleshooting this issue.

Arnel C.

9,361 Points
2013-09-18 8:54 pm EST
Thanks Arnel and John for your help.

Let me clarify what happened. I changed my primary domain. I also wanted to move Moodle from a subfolder to a subdomain as it seemed easier to work with subdomains than subfolders.

I backed up my moodle install, and my courses. Then, I tried the migration as John wrote above, but it did not look like something that I could do. Therefore, I decided to install moodle again and import the old stuff.

I hoped that I could import the whole moodle backup using Softaculous, but that was not possible. Therefore, I installed a new moodle on the subdomain. I then tried to import my courses (I only have 4 of them so it is not so hard to do so). I got this database error. It also sometimes came up when I did various things in moodle.

I have finally managed to import the courses. In general, moodle works, but it is often slow or hangs sometimes. Every so often, it will stop for 2-3 minutes then give the same database error.

As for versions, both moodle installs were/are the newest, 2.5.2 .

As Arnel suggested, I have turned on debugging at the highest level. When I find an error message, I'll post it here. (Is that secure?)

Thanks for the help.
59 Points

2013-09-19 3:15 am EST
General error messages are perfectly fine to post here as any Moodle user may be having the same issue. Of course, do not post anything account specific like usernames and passwords.
1,122 Points
2013-09-19 8:21 am EST
Hi, It has not been doing it so much lately, but just now, I got an error when I tried to log in. This is the code that it has given me:

Debug info: MySQL server has gone away
SELECT name, id, enabled FROM mdl_message_processors ORDER BY name DESC
[array (
Error code: dmlreadexception
Stack trace:

line 423 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1005 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1226 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 1177 of /lib/dml/moodle_database.php: call to moodle_database->get_records_select()
line 2292 of /message/lib.php: call to moodle_database->get_records()
line 3596 of /lib/pluginlib.php: call to get_message_processors()
line 44 of /admin/settings/plugins.php: call to plugininfo_message->load_settings()
line 6416 of /lib/adminlib.php: call to require()
line 3367 of /lib/navigationlib.php: call to admin_get_root()
line 3272 of /lib/navigationlib.php: call to settings_navigation->load_administration_settings()
line 718 of /lib/pagelib.php: call to settings_navigation->initialise()
line 734 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
line 133 of /blocks/settings/block_settings.php: call to moodle_page->__get()
line 292 of /blocks/moodleblock.class.php: call to block_settings->get_content()
line 238 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
line 951 of /lib/blocklib.php: call to block_base->get_content_for_output()
line 1003 of /lib/blocklib.php: call to block_manager->create_block_contents()
line 353 of /lib/blocklib.php: call to block_manager->ensure_content_created()
line 28 of /theme/aardvark/layout/general.php: call to block_manager->region_has_content()
line 860 of /lib/outputrenderers.php: call to include()
line 790 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
line 101 of /index.php: call to core_renderer->header()
59 Points

2013-09-19 10:38 am EST
Hi Joe,

Thanks for posting the version info and debug messages. I'm going to post a message for you in the forums to ask for help in regards to this issue, as it's not something we've seen before. I had one further question. When you are importing the courses into your new Moodle 2.5.2 installation, where are you importing them from? The backup that you initially made? I just wanted to make sure where the courses were coming from.

Arnel C.
9,361 Points
2013-09-19 12:40 pm EST
Are you sure that this is just a Moodle problem? My wordpress sites are doing the same thing now. Sometimes, they hang for minutes then I get a "unable to connect to database" error message.
I also tried to install wordpress with Softaculous and it said that it could not find mysysql.

Instead of referring me to other pages, could you please have a look at the database?
59 Points

2013-09-20 11:00 am EST
Are you sure that this is just a Moodle problem? My wordpress sites are doing the same thing now. Sometimes, they hang for minutes then I get a database error message.
Then, I tried to install wordpress with Softaculous to make a new blog, and it stops at 95% for 5-6 minutes, and then it said that it could not find mysysql.

Instead of referring me to other pages, could you please have a look at the database? Something seems likely to be wrong.
59 Points

2013-09-20 11:02 am EST
Want to share this Question?

News / Announcements

Update to SSL Certificates - Certificate Warnings
1969-12-31 11:00 am EST
Hits: 658

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.