Tuesday, 1 May 2012

Help! I'm locked out of my Cacti server

There's two stages of locked out.

  • You've forgotten just the admin password to the Cacti web interface
  • You've forgotten the admin password and you've forgotten the mysql database password.
The first is relatively easy to sort

Log into the cacti database and run this
mysql -u root -p <cacti db>
update user_auth set password=md5('newadminpassword') where username='admin';

Now of course you might now know which what the cacti database is called in which case
mysql -u root -p
mysql> show databases;

Look for the database which has some snmp tables in it
mysql> connect <database>;
mysql> show tables;

Now if you can't remember the root password to your Cacti database you need to reset that first. It's not the same as the root password on the server. This is how to reset it.

Create a new ini file, let's call it mysql-ini containing
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
FLUSH PRIVILEGES;

Shutdown mysql if it is running and restart it directly with this ini file:
mysqld_safe --init-file=mysql-ini &

Now login with the new root password then shut down mysql again. It can now be restarted with the original start script (and ini file) and you can log in with the new root password.  




No comments:

Post a Comment