Lost MySQL password [duplicate]

Solution 1:

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!