robinder singh
robinder singh

Reputation: 27

Unable to update root Mysql Password

I am unable reset mysql password using below query:

UPDATE mysql.user 
SET authentication_string=PASSWORD('root') 
WHERE user='root' 
  and host='localhost'; 

i am getting below error:

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 '('root') WHERE User = 'root' AND Host = 'localhost'' at line 1

Upvotes: 1

Views: 648

Answers (1)

tadman
tadman

Reputation: 211560

As @spencer7593 points out, the PASSWORD() function was removed in MySQL 8.0 so this code won't work any longer even if it did in previous versions. The syntax error arises because, not recognizing that as a function, the ( character following it is unexpected and a syntax error.

This is because in addition to (previously) being a function it still a keyword.

The way you should be adjusting passwords is either through the mysqladmin command-line tool, or via the SET PASSWORD statement:

SET PASSWORD FOR 'root' = '...'

Upvotes: 1

Related Questions