0

I'm trying to execute

ALTER USER 'root'@'localhost' IDENTIFIED BY 'my_new_password';

but getting

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'my_new_password'' at line 1

What am i doing wrong?

1
  • Which version are you using? That SQL works from 5.7.6 version. Commented Jan 2, 2017 at 9:07

1 Answer 1

3

The way you want to change the password is only valid since MySQL 5.7.6. You can use the SET PASSWORD statement for older versions instead:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('my_new_password');

The ALTER USER statement is available since MySQL 5.7.6. Make sure you are using this version or a newer one to use your statement (thx @Dez).

Sign up to request clarification or add additional context in comments.

1 Comment

The way he wants to change the password is valid since version 5.7.6. dev.mysql.com/doc/refman/5.7/en/alter-user.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.