Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to move the MySQL tables so them were in another folder, so I messed out the plugins table or something like that and I ended up reinstalling the whole thing.

I did sudo aptitude purge mysql-server then I removed the MySQL data rm -rf /var/lib/mysql/mysql and also I removed the data from the other directory I was trying to move the tables.

After reinstallation I supposed I would be able to login using mysql -u root but it said the user was wrong. I tried with the old password and the same thing. Then I searched for a way to reset the root password.

So I did mysqld_safe --skip-grant-tables then I logged in mysql -u root succefully adn then I tried UPDATE user SET Password=PASSWORD('new-password') where User='root'; with no luck, 0 rows affected. Then I did SELECT * FROM User and all I got was debian-sys-maint, nothing more, no root or any other user.

Any little help will be appreciated =/

share|improve this question
up vote 1 down vote accepted

Just create the users you need. There may no root@localhost per default.

You could always connect via mysql --defaults-file=/etc/mysql/debian.cnf

Create your new root user with: GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'YOUR NEW PASSWORD' WITH GRANT OPTION

share|improve this answer
But I have to add the permissions manually – Zequez Aug 21 '11 at 22:41
added how you could recreate the root user – Thomas Berger Aug 21 '11 at 22:44

Since you only removed /var/lib/mysql/mysql , the reinstall wouldn't have created the default dbs since the data dir (/var/lib/mysql) still exist. Rename the data dir and try a reinstall once again. You can restore the dbs from the backup once you are set with the root account.


share|improve this answer
aptitude purge should have been enough – Thomas Berger Aug 22 '11 at 7:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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