Search code examples
mysqlrootprivileges

Username 'root' can be changed in mysql or i can suppose there always be a user named 'root' having all privileges?


Question explain itself. In mysql i can always suppose there will be a user named 'root' having all privileges or the name can be changed? I'm writing a shell script that needs to do some administrative task on a database and i was guessing if i have to ask user only root password or root username too.


Solution

  • Yes you can(After logging into mysql) :

    use mysql;
    update user set user='urDesiredName' where user='root';
    

    Mysql is a database that contains user regarding information like names, roles, priviledges etc informations.

    do flush privileges; It will only clear the db cache and will reset root to [userNewRoot].