Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've having some very weird issues with my MySQL (5.5) root user. I'm trying to allow an external host to access the root user, but it seems as though my root@localhost does not have "GRANT OPTION" to the local databases! I think the issue at this point is caused by the fact that I think I have two root@localhost users, both with different grant rules, but I can't figure out how to get back into my install.

I've already tried deleting the root user and recreating it (I think), resetting the root users password (modifying the mysql database itself)

I can't get into the root account using the password I've always specified but rather an alternate password, which I don't even know how I got... this alternate user is the one that doesn't seem to have full root permissions, yet is still called root.

--SOLUTION POSTED BELOW--

share|improve this question

4 Answers 4

You can start MySQL with the authentication disabled. From there you can create/delete the administrative account for MySQL.

The details you can find in the MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

  1. Shutdown MySQL
  2. Start MySQL with: mysqld --skip-grant-tables --skip-networking
  3. In mysql run:

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

    GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION;

  4. Shutdown MySQL

  5. Start MySQL as you usually do.
share|improve this answer
    
Did that and still getting mysql> GRANT ALL ON . TO 'root'@'*********' IDENTIFIED BY '************************************'; ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) –  Matthew Salsamendi Mar 2 '13 at 0:37
    
this means you did not use --skip-grant-tables –  Mircea Vutcovici Mar 2 '13 at 1:06
    
I actually did use --skip-grant-tables as instructed, and logged in and made the changes as requested. After restarting MySQL normally we still cannot grant granting powers to all databases using the root user. –  Matthew Salsamendi Mar 2 '13 at 1:13
    
you need to connect from localhost. If you want to connect remotely, you have to run also: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION; –  Mircea Vutcovici Mar 2 '13 at 1:21
    
I am connecting from localhost to run that command. However, I can't seem to execute that command, even from localhost. –  Matthew Salsamendi Mar 2 '13 at 1:23
up vote 1 down vote accepted

Found the solution -- This is caused by updating MySQL from MySQL 5.1 to MySQL 5.5 and moving the authentication schema (the MySQL database itself) along with it. As there are core updates to this schema using it with a 5.5 database simply won't work causing two main bugs: Cannot GRANT privileges as root Mysql users deleted

share|improve this answer

You should remove the extra root@localhost entry. This can be done either with "--skip-grant-tables" as suggested by Mircea Vutcovici or in a normal session (local or remote) if you can still access as root.

Try something like this:

#get to admin tables
use mysql
#confirm the differences for the root entries
select host, user, grant_priv from user where user = 'root'; 
#adjust as needed
delete from user where user = 'root' and host = 'localhost' and grant_priv = 'N';
#commit
flush privileges;

Update: According to the output you showed for the select test, it doesn't appear that you have a problem with multiple roots with different grant_privs. Therefore, if the advice given by Mircea Vutcovici doesn't fix your problem, I might guess that the real problem does lie with root privs. Maybe you're doing something else incorrectly like trying to connect to the wrong host or using a password saved in a config file (.my.cnf). In other words, you might need to be more specific.

share|improve this answer
    
This is what I get when I do the select statement: –  Matthew Salsamendi Mar 3 '13 at 7:35
    
+-----------+------+------------+ | host | user | grant_priv | +-----------+------+------------+ | localhost | root | Y | | 127.0.0.1 | root | Y | +-----------+------+------------+ –  Matthew Salsamendi Mar 3 '13 at 7:36
    
These roots clearly do not have different grant_privs so it seems like this wasn't the problem. I suggest you give more detail. Maybe output of "select * from user where user = 'root'\G". [Note the "\G" rather than ";".] –  igelkott Mar 3 '13 at 15:38
    
Here's the result of that: pastebin.com/xxW5q3Xb –  Matthew Salsamendi Mar 6 '13 at 4:26
    
According to this, local root has all privileges, exactly as is should. So, you "should" be able to create a remote root user with: "GRANT ALL PRIVILEGES ON *.* TO root@otherhost IDENTIFIED BY 'secret' WITH GRANT OPTION;". Of course, replace "otherhost" and "secret" as appropriate. Maybe this is what you tried from the beginning but just need to check. –  igelkott Mar 6 '13 at 19:31

Typing SHOW GRANTS FOR 'root'@'localhost'; showed me some obscured password, so I logged into mysql of that system using HeidiSQL on another system (using root as the username and the corresponding password) and typed
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'thepassword' WITH GRANT OPTION;

and it worked when I went back to the system and logged on using
mysql -uroot -pthepassword;

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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