3

When I try

sudo mysql -uroot -p

I get no errors, but it appears I'm not logged in as root, since:

SELECT USER(),CURRENT_USER();

returns:

+----------------+----------------+
| USER()         | CURRENT_USER() |
+----------------+----------------+
| root@localhost | @localhost     |
+----------------+----------------+

and I'm unable to perform any administrative commands like GRANT or UPDATE, I can only view information_schema table.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
van_folmert
  • 4,257
  • 10
  • 44
  • 89

1 Answers1

0

http://dev.mysql.com/doc/refman/4.1/en/information-functions.html#function_current-user says:

The value of CURRENT_USER() can differ from the value of 
USER(). ... One way this might occur is that there is no 
account listed in the grant tables for davida.

If you can't login as root, you can start MySQL without permissions checks: How to start MySQL with --skip-grant-tables? or start mysql with a init file http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html. For the second option, you should use INSERT instead of UPDATE since your table doesn't have the root user.

Community
  • 1
  • 1
Andrei B
  • 2,740
  • 17
  • 12
  • ok, but how to edit grant tables without access to root user? – van_folmert Jul 13 '14 at 12:32
  • 1st solution didn't work for me (I'm still anonymous), after 2nd I get error `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)` when trying to access mysql – van_folmert Jul 13 '14 at 12:55
  • Did mysql restart after 2? It's possible that an error in the init file prevented it from restart. In that case revert that. This page would be more helpfull to you: http://www.helpfromfriend.com/database/mysql/how-to-recreate-root-account-in-mysql/ It combines both 1) and 2) to be on the safe side. – Andrei B Jul 13 '14 at 13:10