User root mysql without permission

Asked

Viewed 11,438 times

4

I’m having a problem changing permissions of users in mysql with the root user in Debian.

I can access normally through the terminal:

$ mysql -u root -p

So he asks me for 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;

He returns me the following message:

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

And if I try to command:

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

it returns the error:

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

I am trying to free root user access, or even create another user for access from other network machines.

1 answer

5


  1. Stop mysql and restart with the option --skip-grant-tables.
  2. Connect to mysql only with the command mysql (without the -p, it should not ask user)
  3. Insert the following command into 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';

  • Thank you for the reply. I can’t access mysql without just using the mysql command, it tries to access with the user q I have logged into the machine. If I access with root and run this command q you passed, it works will be?

  • I believe so

Browser other questions tagged

You are not signed in. Login or sign up in order to post.