Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename Root @ local host username mySQL

Tags:

mysql

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'
like image 392
David Smith Avatar asked Apr 02 '13 15:04

David Smith


People also ask

How do I change the root name in MySQL?

use mysql; update user set user='admin' where user='root'; flush privileges; That's it.

How do I change my MySQL username?

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'.

Can I change root user name?

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.

What is the root username for MySQL?

The default user for MySQL is root and by default it has no password.


2 Answers

Try this

UPDATE mysql.user set user = <newrootname> where user = 'root';
FLUSH privileges;
like image 89
Abimaran Kugathasan Avatar answered Sep 22 '22 14:09

Abimaran Kugathasan


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;
like image 24
pallavi Avatar answered Sep 19 '22 14:09

pallavi