Two days ago i was just about to reinstall the whole server (web, db, mail and fileserver). The reason was, that mysql was apparently not able to open most databases. The files were still there (under /var/lib/mysql), but only two databases which belonged to two gregarius-installations were accessible. I had just installed the aggregator at solidworks.toomuchcookies.net and had instructed the installer to create the database needed. I gave him root-access and also told him to access that database after that as root.
And that was the problem: The installation procedure involved creating the database and granting the user (in this case root himself) on localhost only rights to that database - not on all databases. After that the mysql.users table had a line which granted root/password/localhost only access to two databases and another line which granted root/password/bigcook root access to all privileges. The second line came first and was therefor ignored. I even wasn't able to access the mysql-database, which hods information about the user privileges..
To solve the problem (after an hour and a half of desperate searching and trying to 'recover' the data) i had to start mysql with the "--skip-grant-tables" parameter.
-
/etc/init.d/mysql stop
-
mysqld --skip-grant-tables &
This is a rather dangerous mode and should be handled with care, since it instructs mysql to ignore the privilege table and allow all users access. I used this mode to verify that the databases were still there and then moved on to see the mess created in the mysql.users table. By removing the second grant line, the server was finally able to read all the databases. Phew!
Don't forget to stop the server and restart as daemon:
-
killall mysqld
-
/etc/init.d/mysql start