Problem with moodle and mysql user password

Problem with moodle and mysql user password

Luis Corona -
回帖数:7

Hi, I have a problem with moodle, for certain reasons I had to changed the database user password for a installed moodle, the moodle suystem use mysql, I chaged the file config.php and the password in database too, used the sql sentence:

mysql>gran all privileges on moodle.* to moodleuser@localhost identified by 'password';

the query ejecuted succesfully but in the moodle aplication appear the error message:

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

I'm sure that moodle use a encrypted algorithm for the user database password,and when I changed the database password manually don't match with the config.php file, the questions are ¿how changue the database user password? ¿how I must encrypt the password for match?.

回复Luis Corona

Re: Problem with moodle and mysql user password

Neil S -
If you change the mysql user password you should only need to change config.php - you do not need to worry about the encryption. the password should be plain text in config.php. Mysql uses an encryption algorithm in mysql.users and/or mysql.db but again you do not need to worry about that...

Did you execute either...
mysql> flush privileges;
---or---
mysqladmin -u root -p flush-privileges

After you flush privileges does it either start working or... Can you issue 'mysql -u moodleuser -p YOURMOODLEDBNAME' and when prompted enter the new password to see if you can connect.

Neil


回复Neil S

Re: Problem with moodle and mysql user password

Luis Corona -
When prompt from mysql console with the new password, it´s works, but in the system the error message still appears, I have another moodle application that works fine in other server with the same user and password, if I see this mysql user database, the encrypted password from the user is diferent that I have in the server that don´t work,the ecrypted passwords don't have the same number of characters, that's me suspect that moodle have is own encrypted password method, but maybe is for another reason.
回复Luis Corona

Re: Problem with moodle and mysql user password

Neil S -
Did you update config.php in your moodle root folder (where moodle is installed) after you changed the mysql user password?

You may need to do this with a text editor on the server via ssh... or ftp the file down, change it, then put it back up.

The passwords as they are stored in the db may be different because depending on what version of mysql you use and how it's configured it may hash them with different algorithims before storing them. None of this should matter, however, so long as you have the correct mysql client libs compiled correctly with php because config.php has the password only in plain text.

Neil
回复Neil S

Re: Problem with moodle and mysql user password

Luis Corona -
Yep, I first changued the password in config.php moodle root folder, via ssh, and after changued the mysql user password, but the application stills shows the error message 伤心 ,the moodle version is 1.8.2.
回复Luis Corona

Re: Problem with moodle and mysql user password

ETH Zürich -

Hi luis,

execute flush command or restart mysql!

cheers from Amr Hourani

回复ETH Zürich

Re: Problem with moodle and mysql user password

Luis Corona -
I did that, in mysql console the grant command :grant all priviliges on moodle.* to 'moodleuser'@'localhost' identified by 'password'; restart the mysql service, but the error still appear, other appliactions that use mysql work fine, only moodle no, I really will surrender soon, and have to reinstall everything, but thanks for the help, if the problem isn't encrypt with moodle code that connects to database, I don't know what can be.
回复Luis Corona

Re: Problem with moodle and mysql user password

Andrew Coile -
I hope you replaced 'password' with whatever is the password as defined in your config.php....don't just blindly put the word 'password' in the "identified by 'password'" part.

It also assumes that the database user defined in config.php is 'moodleuser', i.e. config.php contains:

$CFG->dbtype = 'mysql';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodleuser';
$CFG->dbpass = 'WHATEVERYOURPASSWORDISHERE';