Ok, I know I'm stupid. I deleted all privileges to MySQL, I have access to root account on host. Is there any way to add account to mysql?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

First of all stop mysql & backup /var/lib/mysql or wherever the data files are on your system.

Then from a clean mysql install elsewhere tar up /var/lib/mysql/mysql and put it on the broken system.

Then re-add your users & permissions.

Of course if you have backed up the mysql database you can do this more quickly.

link|improve this answer
feedback

I have a nice set of Linux commands you may want to run every night to backup your MySQL permissions:

mysql -u -p --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql -u -p --skip-column-names -A | sed 's/$/;/g' > MySQLGrants.sql

This will literally spill out the grants for all users as SQL GRANT Commands.

MAATKIT also does this using their perl script mk-show-grants

That way if you hose all your permissions, you can do three(3) things:

  1. apply the suggestion by @jamespo
  2. login to mysql as root@localhost
  3. Run MySQLGrants.sql
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.