Bug #66153 Hacking MySQL privileges
Submitted: 2 Aug 2012 6:26 Modified: 3 Aug 2012 18:00
Reporter: Brandon Sky Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S2 (Serious)
Version:5.1.61 OS:MacOS (How to hack MySQL privileges?)
Assigned to: CPU Architecture:Any
Tags: hack, MySQL, privileges, root

[2 Aug 2012 6:26] Brandon Sky
Description:
I am currently locked out of my MySQL database server. I'm trying to reset the root password but I don't have the appropriate privileges. Without a password I cannot log in to phpMyAdmin.

When running the queries told in http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html, I get these errors:

ERROR 1142 (42000): UPDATE command denied to user ''@'localhost' for table 'user'
ERROR 1227 (42000): Access denied; you need the RELOAD privilege for this operation

Any way to hack those privileges?

How to repeat:
1> Go to Terminal and type 'mysql'
2> Run these SQL queries:
UPDATE mysql.user SET Password=PASSWORD('') WHERE User='root';
FLUSH PRIVILEGES;
3> You will get these errors

Suggested fix:
↓ PLEASE COMMENT BELOW FOR FIXES ↓
[2 Aug 2012 8:43] MySQL Verification Team
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.

Easier:
1. start server with --skip-grant-tables and login
2. update the mysql.user table as needed
3. flush priviliges
[2 Aug 2012 8:56] Brandon Sky
Because of the password required for all tasks, I am completely locked out of my MySQL server. Reopening.
[2 Aug 2012 8:57] MySQL Verification Team
I assure you, if the server is started with skip-grant-tables in the [mysqld] section of my.ini, or --skip-grant-tables on the command line, no password is needed to login :)
[2 Aug 2012 9:00] Valeriy Kravchuk
Also read that manual page you quoted carefully. It suggests to put that UPDATE into a file and pass file name as --init-file to mysqld_safe, or, later, to start server with --skip-grant-tables. So, please, just follow the manual.
[2 Aug 2012 9:20] Brandon Sky
Reopened; opening mysqld returns this:

120802  6:18:24 [Warning] Can't create test file /usr/local/mysql-5.1.61-osx10.6-x86_64/data/thepimentafamily.lower-test
120802  6:18:24 [Warning] Can't create test file /usr/local/mysql-5.1.61-osx10.6-x86_64/data/thepimentafamily.lower-test
/usr/local/mysql-5.1.61-osx10.6-x86_64/bin/mysqld: Can't change dir to '/usr/local/mysql-5.1.61-osx10.6-x86_64/data/' (Errcode: 13)
120802  6:18:24 [ERROR] Aborting

120802  6:18:24 [Note] /usr/local/mysql-5.1.61-osx10.6-x86_64/bin/mysqld: Shutdown complete

And entering this in the command line:

$ mysql -u root mysql

returns this:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

------------------------------------------------------------------------------

That means my MySQL server is completely locked. Any way to unlock the server?
[3 Aug 2012 18:00] Sveta Smirnova
Thank you for the feedback.

You problem is result of wrong setup, not wrong MySQL behavior and should not be discussed here. We are not allowed to provide free support for such cases.

Please either open customer SR or ask same question on public forum.