Root mysql user without permission

4

I'm having a problem changing user permissions in mysql with the root user, in Debian.

I can usually access the terminal:

$ mysql -u root -p

So he asks me the root password, I put the password and normal access. However, when I try to execute the command:

mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'senha_do_usuario' WITH GRANT OPTION;

It returns me the following message:

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

And if I try the command:

CREATE USER 'user'@'%' IDENTIFIED BY 'senha';

it returns the error:

ERROR 2013 (HY000): Lost connection to MySQL server during query

I'm trying to free access to the root user, or even create another user for access from other machines on the network.

    
asked by anonymous 20.08.2014 / 15:58

1 answer

4
  • Stop mysql and restart with --skip-grant-tables option.
  • Connect to mysql only with the command mysql (without -p , it should not prompt for user)
  • Enter the following command in the sql client:

    UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';

    FLUSH PRIVILEGES;

  • After that you should be able to use the command GRANT ALL ON *.* TO 'root'@'localhost';

        
    20.08.2014 / 16:17