parsa
parsa

Reputation: 45

ERROR 1045 (28000): Access denied for user 'root'@'%'

I am trying to run

GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost';

from a remote server to localhost/phpmyadmin but getting ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: NO).

mysql> show grants;
+----------------------------------+
| Grants for root@%                |
+----------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
+----------------------------------+

How can I resolve this problem? I have gone through a lot of suggestions over internet but can't actually figure out.

Upvotes: 2

Views: 4151

Answers (2)

Rohit Arya
Rohit Arya

Reputation: 6791

I think, you forgot to flush privileges.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with GRANT OPTION;
mysql> FLUSH PRIVILEGES;

Note: I have included with GRANT OPTION because as doc says:

The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.

Edit 1:

Depending on comments, seems like you have forgotten the root password. So try to reset like this:

  1. Stop the MySQL Server.

    sudo /etc/init.d/mysql stop

  2. Start the mysql without password

    sudo mysqld_safe --skip-grant-tables &

  3. Login to mysql as root:

    mysql -u root

  4. Set new password to root

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

  5. Flush privileges.

    FLUSH PRIVILEGES;

  6. Finally, restart mysql normally.

Upvotes: 3

kamlesh
kamlesh

Reputation: 38

If you have root credential , then Set the privileges like mentioned below.

grant all privileges on db.* to user@'%' identified by 'pass';

Thanks

Upvotes: 0

Related Questions