admin account locked out

admin account locked out

by Stan Hoeppner -
Number of replies: 11
I am not the moodle admin, but the linux admin, so I have almost zero experience with the administrator interface.  I'm not a mysql guru either unfortunately.

Our Dean of Faculty is the Moodle guy.  He has lost his account access, and his account was the single moodle administrator account.  Interestingly, every other account is still able to login, but his is broken.  All the teachers and students can log in.

So, obviously we need to re-enable that account, or create a new admin account.  I'm assuming it can't be done through the web interface.

Is there a way for me to create a new moodle admin account from the Linux shell command line? 



Thanks in advance for the help.

Stan Hoeppner
Systems Admin
Whitfield School
St. Louis, MO
Average of ratings: -
In reply to Stan Hoeppner

Re: admin account locked out

by colin alteveer -

if you have access to phpmyadmin or mysql for the moodle instance the easiest way is to screw with the database "user" table. find an account where someone does know their password and:

SELECT password FROM user WHERE username = ';'

save the result set, it should be a 40(?) digit hash. then:

UPDATE user SET password = '' WHERE username = 'admin'

the admin's password will now be same as the volunteered account's and the admin can log in with that password and change it!

remember: there is always a mysql login/password in the moodle/config.php, and you should be able to do all of this inside of 'mysql' from the linux shell.

this is of course assuming that it is simply an issue of a missing password. if not, let me know, i will attempt an account retrieval howto

cheers!

In reply to Stan Hoeppner

Re: admin account locked out

by Ken Wilson -

Stan

Take a look at this in the Administration FAQs. There is a link to Shane Elliott's passchange.php script which is a very neat way of resetting any user's password. Because of the security issues, it's best to delete the script from your moodle/ folder when done wink.

Ken

In reply to Ken Wilson

Re: admin account locked out--HELP!!

by Stan Hoeppner -
I really need some serious help here.  Not only can the moodle admin user not login, but now no one can log in.  I used to be able to fix the no users login problem by rebooting the server.  Now this doesn't fix the problem.

Also, somehow the root account can no longer access the database(s).   I've seen errors in /var/log/messages pertainting to some cron'd database maintenance failing because the root user password is incorrect

Some background on my moodle installation:

Instead of building a server from scratch, I used the VMware virtual appliance downloaded from the VMware website:

http://www.vmware.com/vmtn/appliances/directory/287

It was created by Farren Constable.  (Farren can you please help??!!?)

The system is SuSE 10.1.  After the initial installation I changed the root password, for obvious reasons.  It appears that the root password change broke the root account from being able to access the databases.  Also, the sql admin account "admin" cannot access the databases either.  Or is this not the actual name of the sql admin account.

I've got so many problems going on (it seems like multiple problems anyway) that I don't know where to begin.

I've read a bunch of administration posts about fixing the moodle admin user password.  I read a post about changing the sql admin password, but it didn't give the EXACT command line syntax.  I am a complete mysql nubie.  I don't, AFAIK, have any of the sql admin GUI tools.  I can acces "mysqladmin" from the command line, but at present I can't do a thing because it seems all the passwords are incorrect.

Someone please help!!  I need to have this all fixed up by tomorrow.

Help!

 
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by Simon Bryan -
Not really a complete answer, but the admin user in mysql is normally 'root' but it has a different password to the root user on the system. So if you are using the new root password try the old one on MySql

I would get a copy of MySQL Admin from the MySQL site and try to get a connection to your database with that first
In reply to Simon Bryan

Re: admin account locked out--HELP!!

by Stan Hoeppner -
I've installed mysql-admin.  When I try to log into the database I get an error that my host (my workstation, where I installed the tools) is not allowed access to the database.  What file do I edit to allow my workstation to connect?
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by colin alteveer -
Stan,

  got your message just now, please disregard the reply.
  you might try simply "mysql -u root" to see if a root password is even set. otherwise, it looks like you are in a bit of pickle. i like the idea of running through all the old passwords, and also you might try checking the moodle config.php for a password to your database.
  when you bring up moodle in a browser window do you have an db errors?
In reply to colin alteveer

Re: admin account locked out--HELP!!

by Stan Hoeppner -
moodle:/var/log/apache2 # mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

AFAIK, I've tried all the old passwords, to no avail.

Where the heck is moodle config.php?  I can't seem to find it.

Bringing up moodle in a browser gives no DB errors, and low and behold, I can log in again with a regular moodle user account.  I dont get it.   I haven't changed anything since yesterday, but yesterday no regular moodle users could log in.  Currently, course content shows up, and the site seems to be running 'normally'.  All of the links I've tested work.

Also, something I forgot to mention earlier.  I've noticed that the directory  /var/log/apache2/ on occasion gets set as a 'read only' filesystem, which is inexplicable.  Don't know if this helps any.

Also, here are some errors I'm getting in /var/log/messages:

Sep 17 16:00:02 moodle logrotate: /usr/bin/mysqladmin: connect to server at 'localhost' failed
Sep 17 16:00:02 moodle logrotate: error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Sep 17 16:00:02 moodle logrotate: /etc/logrotate.d/mysql failed, probably because
Sep 17 16:00:02 moodle logrotate: the root acount is protected by password.
Sep 17 16:00:02 moodle logrotate: See comments in /etc/logrotate/mysql on how to fix this
Sep 17 16:00:02 moodle logrotate: error: error running postrotate script for /var/lib/mysql/mysqld.log

I looked for /etc/logrotate/mysql for help, but the logrotate directory doesn't even exist...
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by Stan Hoeppner -
Ok, finally some progress.  I can log into mysql finally using

mysql -u=admin

with no password.

So, now maybe I can finally try using some of the hints above to reset the administrator password.
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by Stan Hoeppner -
Ok, I used Shane's passchange script.  I works on a normal user account, but not the admin account.  Thus, I believe the admin account somehow got deleted.

So, I guess I need to create a new moodle admin account.  Any ideas?  I'll search the forums for it.  It's probably come up before.

I'd still like to be able to fix the logrotate and some other things that are broken, also apparently due to rights.
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by Stan Hoeppner -
Thank you all so much for your help!

I was able to turn an account into an admin and regain "control" of our moodle server.

I haven't been able to get a primary admin set,  but that's not a big deal now that I can assign administrators from the mysql command line.

Stan
In reply to Stan Hoeppner

Re: admin account locked out--HELP!!

by Casey Fisher -

Ihave an issue with this code Could not create guest user record !!!. I have read about the sql and phpmyadmin, but I cant figure out how to use any of it.  I am new to MOODLE managing.  Can anyone help me out in laymans terms?