3

I am struggling with granting privileges to mysql user.

I tried following command:

GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'userpassword' WITH GRANT OPTION;

But it returns following error:

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

I know that this is indicating to wrong password, but I am sure that my password is correct, now what can be the issue, Please suggest if anybody knows the solution to this problem.

Update :

mysql> SHOW GRANTS;
+------------------------------------------------+
Grants for mysun@localhost
+------------------------------------------------+
GRANT USAGE ON *.* TO 'mysun'@'localhost' IDENTIFIED BY PASSWORD
GRANT ALL PRIVILEGES ON xxxx_xxxxx.* TO 'mysun'@'localhost'
GRANT ALL PRIVILEGES ON xxxx_xxxxxxxx.* TO 'mysun'@'localhost'
GRANT ALL PRIVILEGES ON xxxx_xxxxxxxxx.* TO 'mysun'@'localhost'
+------------------------------------------------+
4 rows in set (0.00 sec)

Martin
  • 22,212
  • 11
  • 70
  • 132
Shishupal Shakya
  • 1,632
  • 2
  • 18
  • 41
  • Run `SHOW ALL PRIVILEGES for 'mysun'@'localhost'` and copy that result. – Raymond Nijland May 28 '19 at 13:27
  • 2
    And I would opine that it's very bad practise to give any user *ALL* privileges. You're setting yourself up to be breached. – Martin May 28 '19 at 13:27
  • 2
    Your current account does not have permission to run the GRANT command. – PeterHe May 28 '19 at 13:27
  • 1
    Possible duplicate of [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – Martin May 28 '19 at 13:29
  • 1
    **Does not compute** Your [last question](https://stackoverflow.com/questions/56342791) Says you cannot connect to the database, and now you are suggesting that you are connected and getting this error? Which one is it?? – RiggsFolly May 28 '19 at 13:29
  • maybe he runs more then one MySQL server? @RiggsFolly but who knows – Raymond Nijland May 28 '19 at 13:31
  • @RiggsFolly So one of the developers suggested in a comment to GRANT permission in my previous question, so when I ran command to grant permisson I am getting this error thats why I posted it here. – Shishupal Shakya May 28 '19 at 13:33
  • @RaymondNijland Now I am getting this error : ERROR 1227 (42000): Access denied; you need (at least one of) the RELOAD privilege(s) for this operation – Shishupal Shakya May 28 '19 at 13:34
  • Are you using a SuperUser account like `root` or a low level user account – RiggsFolly May 28 '19 at 13:34
  • ....... Obviously not a SuperUsers :) – RiggsFolly May 28 '19 at 13:35
  • o yes sorry wrong syntax `SHOW ALL PRIVILEGES for 'mysun'@'localhost'` should be `SHOW GRANTS FOR 'mysun'@'localhost'` or more easy `SHOW GRANTS FOR CURRENT_USER();` – Raymond Nijland May 28 '19 at 13:36
  • 2
    @AndroidDev it sounds like you're fumbling in the dark. Maybe it would be more constructive to go and dig out some online tutorials and read the [**MySQL Documentation**](https://dev.mysql.com/doc/refman/5.7/en/grant.html) for a day before returning to your issue with new knowledge `:-)` – Martin May 28 '19 at 13:36
  • @RaymondNijland I have updated the question with SHOW GRANTS result. – Shishupal Shakya May 28 '19 at 13:49
  • Do not replace code with an image. Code can be formatted. An image can not. – Martin May 28 '19 at 14:12

0 Answers0