How can I change root username in MySQL

I just wanted to say that for me, there was no column 'password'.

To change password, the correct field was authentication_string

So the command is

update user set authentication_string=PASSWORD('new password') where user='admin';

I'm no MySQL expert, so I'm not sure exactly why, but what I said is correct, at least in my case.


After connecting to MySQL run

use mysql;
update user set user='admin' where user='root';
flush privileges;

That's it.

If you also want to change password, in MySQL < 5.7, run

update user set password=PASSWORD('new password') where user='admin';

before flush privileges;. In MySQL >= 5.7, the password field in the user table was renamed to authentication_string, so the above line becomes:

update user set authentication_string=PASSWORD('new password') where user='admin';

Tags:

Mysql