Database Errors during Install

Database Errors during Install

by Philip Jones -
Number of replies: 4

Moodle 3.1
PHP 7.0.8
MySQL 5.7.15
Ubuntu 16.04 on DigitalOcean

I am installing Moodle 3.1 according to the step-by-step instructions for Ubuntu. All the command line instructions went as expected. However during Step 7, the browser-based portion of the install, I get the following error after submitting the database details.

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'prn_moodle_user'@'localhost' (using password: YES) in /var/www/html/moodle/lib/dml/mysqli_native_moodle_database.php on line 79

As this is a new installation, there is no config.php file yet.

I am able to connect to the database as 'root', but not as the user created for moodle (moodleuser). When I attempt to connect to the DB as 'moodleuser' via the command line, I get the following error.

ERROR 1045 (28000): Access denied for user 'moodleuser'@'localhost' (using password: YES)

I have checked and double-checked the permissions for the moodle user and everything is as it was specified in the instructions. I have also verified the password is correct.

If I SHOW GRANTS for the user, here is what I get:

Grants for moodleuser@localhost

GRANT USAGE ON *.* TO 'moodleuser'@'localhost'

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON `moodle`.* TO 'moodleuser'@'localhost'

I can login as 'root' with no problems, so the database is running. In addition to logging in from the command line, I can log in as 'root' from PHPMySqlAdmin (but not as 'moodleuser').

Any ideas what's going on and how I can fix it? I don't want to run Moodle as 'root'.

Average of ratings: -
In reply to Philip Jones

Re: Database Errors during Install

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Looks to me like you are trying to use two different versions of the database user name.

The warning message is showing 'prn_moodle_user' but elsewhere you show that you are trying to use just part of the name, 'moodleuser'  which is not the same.

In reply to AL Rachels

Re: Database Errors during Install

by Philip Jones -

For the purposes of this post and readability, I intended to replace all instances of 'prn_moodle_user' (the real username) with 'moodleuser', but I missed that one instance.

So, everywhere in my post you see me refer to 'moodleuser', assume that it is actually 'prn_moodle_user'.

Sorry for the confusion.

In reply to Philip Jones

Re: Database Errors during Install

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Ok, I understand. I have had the same problem you describe and each time, I wound up deleting both the user and the database and starting over. I now use phpMyAdmin for database maintenance, and I have learned the most reliable way to get a database with a working user and password is to start by clicking the tab for Users. In the New section I then select, Add user. In the Login Information section I type in a username, host, and generate a password, which I immediately make a copy of into Notepad for later use when running Moodle install. In the, Database for user, section I click the option to, Create database with same name and grant all privileges. I then scroll down and on the bottom right, click Go.

I used these exact steps two or three hours ago to make a new Moodle dev site and it worked first time when I ran the install.

Average of ratings: Useful (3)
In reply to AL Rachels

Re: Database Errors during Install

by Philip Jones -

Cha-ching! We have a winner!

That seems to have taken care of the DB error. Thanks for the assist.

Now I'm getting "Moodle requires the xml PHP extension. Please install or enable the xml extension," but that's another matter.


Thanks again!