Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

This question already has an answer here:

I've tried reinstalling mysql and I've tried the steps outlined here, but none of the commands work without a password.

I'm using Ubuntu, Apache 2.2, and Webmin 1.550.

Thanks in advance!

share|improve this question

migrated from Jul 5 '11 at 19:41

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Chris S Mar 20 '13 at 5:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Well you're messing up something with step number 2 then. – EEAA Jul 5 '11 at 19:51
Step one won't even work without a password. – quadthagoras Jul 5 '11 at 19:53
You're likely confusing the sudo password and the mysql password. The MySQL password has nothing to do with starting and stopping the MySQL process. All you need to restart the process is root-level privileges, either by signing in as root or running /etc/init.d/mysql restart via sudo. – EEAA Jul 5 '11 at 19:55
When I try "sudo mysql stop" it gives me "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)". – quadthagoras Jul 5 '11 at 19:58
that's not the correct command to stop the mysql process. Use /etc/init.d/mysql stop and /etc/init.d/mysql start. – EEAA Jul 5 '11 at 19:59
up vote 7 down vote accepted

I am not sure why reinstalling isn't working. Perhaps you are not wiping out the mysql database (which contains your user passwords in the mysql.user table).

Regardless, you should be able to disable authentication by either stopping mysql and restarting it from command line while including the --skip-grant-tables flag as that tutorial feebly suggests.

Or, more ideally, stop mysql and edit /etc/mysql/my.cnf to include the following line:


Then, start mysql. You should have complete access without needing to authenticate and you can go in and run your password change commands:

use mysql;
UPDATE user SET password=PASSWORD('abetterpasswordthanthis') WHERE User = 'root';
flush privileges;

Then, stop mysql, remove the line from my.cnf if you used that method, start it up and make sure it is requiring passwords again. If so, and your new password works... you are in business!

share|improve this answer
Thanks a lot, it worked perfectly! – quadthagoras Jul 6 '11 at 18:26

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