0

I want to expire a user 'JohnDoe' password. I executed the alter statement below:

ALTER USER 'JohnDoe'@'mysql' PASSWORD EXPIRE;

And the error message:

ERROR 1396 (HY000): Operation ALTER USER failed for 'JohnDoe'@'mysql'

Is it a syntax error or something else? And how can I fix this? Thanks.

Ansun
  • 1
  • 1
  • 2
    Isn't it user@localhost ? – m.qayyum May 22 '19 at 15:19
  • 1
    A syntax error would tell you it was a syntax error. So it's not that. Are you sure you specified the user details correctly? As the comment above notes, it's pretty unusual to call your server `mysql`, although I suppose you might have done. – ADyson May 22 '19 at 15:21
  • @m.qayyum same error when I change to localhost. ERROR 1396 (HY000): Operation ALTER USER failed for 'JohnDoe'@'localhost' – Ansun May 22 '19 at 15:25
  • @ADyson ERROR 1396 (HY000): Operation ALTER USER failed for 'JohnDoe'@'localhost' – Ansun May 22 '19 at 15:26
  • The user alering this does have permissions to do so? – m.qayyum May 22 '19 at 15:28
  • https://stackoverflow.com/questions/5555328/error-1396-hy000-operation-create-user-failed-for-jacklocalhost – m.qayyum May 22 '19 at 15:29
  • @m.qayyum yup, it is the root user and have alter privilege – Ansun May 22 '19 at 15:32
  • We didn't say that localhost was definitely correct, just that you should go away and check the correct hostname to specify – ADyson May 22 '19 at 15:32
  • ahh, my local host name is "root@localhost", thanks for the help! – Ansun May 22 '19 at 15:43
  • To be precise, in that example root is the username, and localhost is the host. In Mysql a user's access is defined by both. You can read more about the concepts online if you search – ADyson May 22 '19 at 16:50

1 Answers1

3

I think that you are specifying the user incorrectly. I can recreate your error message if I use the wrong user name or host name. To check the user name and host you could try a query to find the user by name:

select * from mysql.user where `User` = 'JohnDoe';

Then when you have confirmed the user name and host from that table you can use the correct name and host and the statement should work.

ALTER USER 'User'@'Host' PASSWORD EXPIRE;
J. Schmale
  • 446
  • 3
  • 6