Error reading from database Moodle 3.5 when install

Error reading from database Moodle 3.5 when install

by Gokulan N -
Number of replies: 27

Hi,

I tried to install Moodle in localhost using WAMP 3.1.3 64Bit. And I'm using PHP version 7.0.29, MySQL version 5.7.21 (or MariaDB 10.2.14). But I'm unable to install Moodle on this. It says "Error reading from database" when I install. Below screen shows to me. 

Can anyone please help me to fix this and install successfully???


moodle error

Average of ratings: -
In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I am not the expert on this, but maybe I can get you started.

Are you sure that the database is running?  Have you started Apache and MySQL in your WAMP?

Are you sure that you entered the correct database username and password?

How, or maybe a better question, did you create a database before running moodle's install?

In reply to Rick Jerz

Re: Error reading from database Moodle 3.5 when install

by Gokulan N -

First thanks for your response.

Are you sure that the database is running?

Yes. I've checked that. It's working. 

Have you started Apache and MySQL in your WAMP?

Yes. Everything is running.

Are you sure that you entered the correct database username and password?

Yes. I'm sure. I've checked many times

Did you create a database before running moodle's install?

Yes. I did.


I've checked old posts for solutions. And I tried that too. But nothing works....


In reply to Rick Jerz

Re: Error reading from database Moodle 3.5 when install

by Gokulan N -

And below is my config file


unset($CFG);

global $CFG;

$CFG = new stdClass();


$CFG->dbtype    = 'mysqli';

$CFG->dblibrary = 'native';

$CFG->dbhost    = 'localhost';

$CFG->dbname    = 'moodle';

$CFG->dbuser    = 'root';

$CFG->dbpass    = '';

$CFG->prefix    = 'mdl_';

$CFG->dboptions = array (

  'dbpersist' => 0,

  'dbport' => 3306,

  'dbsocket' => '',

  'dbcollation' => 'utf8mb4_unicode_ci',

);

$CFG->wwwroot   = 'http://localhost/moodle';

$CFG->dataroot  = 'E:\\wamp64\\moodledata';

$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;

require_once(__DIR__ . '/lib/setup.php');

In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Alain Raap -
Picture of Particularly helpful Moodlers

Could you share some information of your database logfile? Usually it gives some more information about the error you get.   

In reply to Alain Raap

Re: Error reading from database Moodle 3.5 when install

by Gokulan N -

I checked that log file. But nothing inside related to this issue. In fact, I checked all the log files. But i can't find anything related to this

In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Alain Raap -
Picture of Particularly helpful Moodlers

Did you try dbtype "mariadb"? Can you reach the database with mysql command as root?

In reply to Alain Raap

Re: Error reading from database Moodle 3.5 when install

by Gokulan N -

I tried that too. that's not working 

In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Alain Raap -
Picture of Particularly helpful Moodlers

drop the database and retry to install Moodle.

In reply to Rick Jerz

Re: Error reading from database trying to upgrade 3.8 to 3,9

by Fatima Shaikh -

I am also facing the same problem when I tried to upgrade moodle 3.8 to 3.9.

Please help me resolve the problem.

Thanks & regards

Fatima 

(Edited by Mary Cooch  to change subject title- original submission Tuesday, 16 June 2020, 7:33 AM)


In reply to Fatima Shaikh

Re: Error reading from database trying to upgrade moodle 3.8 to 3.9

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Can you access the database with the dbuser and dbpass in the config.php? The usual tools are either phpMyAdmin or the mysql command line tool.

P.S. Yours is not the same problem as the original thread you joined https://moodle.org/mod/forum/discuss.php?d=374827. I changed the subject line accordingly.
In reply to Visvanath Ratnaweera

Re: Error reading from database trying to upgrade moodle 3.8 to 3.9

by Fatima Shaikh -
Thanks for the prompt reply. Will check.
In reply to Fatima Shaikh

Re: Error reading from database trying to upgrade moodle 3.8 to 3.9

by Fatima Shaikh -
I can access the database through dbuser & dbpass.
In reply to Fatima Shaikh

Re: Error reading from database trying to upgrade moodle 3.8 to 3.9

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
The error message is exactly that in the post https://moodle.org/mod/forum/discuss.php?d=374827, i.e. "It is not possible to recover from errors triggered during installation, you may need to create a new database or use a different database prefix if you want to retry installation"?

That is really odd. It talks about a fresh installation but you said, you are trying to upgrade? You have to give exact steps you have done, ideally in the form of documentation. e.g. https://docs.moodle.org/39/en/Upgrading#Linux ?
In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I suggest trying what the message says.  Delete your database, create a new one and try again.

In reply to Emma Richardson

Re: Error reading from database Moodle 3.5 when install

by Gokulan N -

Actually, i tried that. But nothing works

In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

What is your database server?  Let's start there - is it mysql or mariadb?

Does the user you created have the necessary permissions on the database (read,write, etc)?

That error suggests that you are connecting the database server but something is wrong with the database itself.  

Did you go through the specific instructions for whatever database you have found here: 

https://docs.moodle.org/35/en/Installing_Moodle#Create_an_empty_database

 

 

In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Ste Crz -

For those still getting the "error reading from database" message: I changed 'dbcollation' in the moodle config file (config.php) from 'utf8mb4_unicode_ci' to 'utf8_general_ci' and now it works.

Probably would be better to change the database encoding instead of moodle settings but my host does not allow the change.

In reply to Ste Crz

Re: Error reading from database Moodle 3.5 when install

by Collins Jumah -

Thanks for the solution,,,,, it has been an error for a whole week.... after transferring moodle files to cpanel wit its database.

In reply to Ste Crz

Re: Error reading from database Moodle 3.5 when install

by David Cardona -

Oh man, you saved me hours!!, I was having too the "error reading from database"  when creating a new user on moodle 3.7.2 , i made the change you suggested and everything is working now.

But, which could be the implications of changing the dbcollation on a production site?

In reply to Ste Crz

Ang: Re: Error reading from database Moodle 3.5 when install

by Preben Pedersen -

The 'utf8_general_ci' doesn't support emoji etc. So i went it 'utf8mb4_general_ci' which solved my problem.

In reply to Ste Crz

Re: Error reading from database Moodle 3.5 when install

by Ashraf Mousa -
I already solve this problem by correct the config.php file to match the database from "utf8mb4_unicode_ci" to "utf8_bin" because I made my database as "utf8_bin", so anyone who faces this problem should try this solution.
In reply to Ashraf Mousa

Re: Error reading from database Moodle 3.5 when install

by Jeff Lewis -
I found a similar fix here. I kept getting the error when trying to add a New User or change the email address of a User. Not sure if Softaculous update from 10.5 to 11 was to blame, since hadn't tried to add/update any users from 3.11 through to our latest 3.11.4 incremental updates.

In our case, the dbcollation was 'utf8mb4_unicode_ci', so I simply changed it to 'utf8_unicode_ci'
In reply to Jeff Lewis

Re: Error reading from database Moodle 3.5 when install

by Jeff Lewis -
Unfortunately, removing "mb4" from the dbcollation is not a perfect fix.  It resulted in the following Server check issue:

"mysql_full_unicode_support if this test fails, it indicates a potential problem

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. "
Other Check error from editing config.php dbcollation
In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Paul Flanders -
This is almost always a mis-match of db collation

Database / Tables and any config setting must all match

Paul
In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Syed Khalid Mehmood -
I faced the same issue, But it was due to low disk space on the server where I have diploid my Moodle setup

I resolved it by removing extra files from server
In reply to Gokulan N

Re: Error reading from database Moodle 3.5 when install

by Danny Fu -

We had the same issue after we upgraded our site to version 3.6.10. The following CLI script to convert to the new Character set and Collation in the database solves the problem. 

php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci
https://docs.moodle.org/36/en/MySQL_full_unicode_support