I am trying to rename the root username to something else, I am using the following code, however, I get an error :(
RENAME USER 'root'@'localhost' TO 'chosenName'@'localhost';
I get the following error ...
ERROR 1396 (HY000) : Operation RENAME USER failed for 'root'@'localhost'
use mysql; update user set user='admin' where user='root'; flush privileges; That's it.
UPDATE user set user = 'yourNewUserName' WHERE user = 'root'; To understand the above syntax, let us switch the database to MySQL using USE command. The query is as follows to switch the database. Look at the sample output, we have username 'root'.
Log in using the "root" account and the password you have previously set. Change the username and the home folder to the new name that you want. Change the group name to the new name that you want. Lock the "root" account.
The default user for MySQL is root and by default it has no password.
Try this
UPDATE mysql.user set user = <newrootname> where user = 'root';
FLUSH privileges;
try this it will definitely work but only just make sure no mistake in syntax
mysql> use mysql;
mysql> update user set user="new_user" where user="root";
mysql> flush privileges;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With