Rename Root @ mySQL localhost name

I am trying to rename the root username to another, I am using the following code, however I am getting an error :(

RENAME USER 'root'@'localhost' TO 'chosenName'@'localhost'; 

I get the following error ...

 ERROR 1396 (HY000) : Operation RENAME USER failed for 'root'@'localhost' 
+7
source share
2 answers

try it

 UPDATE mysql.user set user = <newrootname> where user = 'root'; flush privileges; 
+11
source

try this, it will definitely work, but just make sure the syntax errors

 mysql> use mysql; mysql> update user set user="new_user" where user="root"; mysql> flush privileges; 
+2
source

All Articles