0

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!

  • Well you're messing up something with step number 2 then. – EEAA Jul 05 '11 at 19:51
  • Step one won't even work without a password. – quadthagoras Jul 05 '11 at 19:53
  • 1
    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 05 '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 05 '11 at 19:58
  • 1
    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 05 '11 at 19:59
  • On my version of Ubuntu you have to use 'service mysql stop' instead of '/etc/init.d/mysql stop' but when I try to use the first command, it gives me 'stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.62" (uid=1001 pid=5191 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))' – quadthagoras Jul 05 '11 at 20:03
  • I'd recommend just putting the skip-grant-tables option in your my.cnf file and rebooting your server. When mysql starts up, it will do so without loading grants, and then you can re-set the root password. – EEAA Jul 05 '11 at 20:07
  • @pythondude Did you run the `service` command as root (`sudo service mysql stop`)? Running the init scripts will issue a warning, but they still work fine, too. – Shane Madden Jul 05 '11 at 20:34

1 Answers1

7

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:

skip-grant-tables

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!

arkigos
  • 236
  • 1
  • 3