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.
Asked
Active
Viewed 326 times
0
-
1Not always. It can be changed. For example: http://stackoverflow.com/questions/19539028/how-can-i-change-root-username-in-mysql – Stalinko Jul 03 '14 at 10:43
-
1Even if they don't change the root username it's still possible to make the root user locked down to just localhost or make it not have a working password(change the password hash to `*!` is the typical solution). Never trust the root user to work. – scragar Jul 03 '14 at 10:45
-
What do you mean by "change the password hash"? I guess i don't understand what you mean in this case for "hash" – Sasha Grievus Jul 03 '14 at 11:03
-
1MySQL stores a hash of your login users passwords, this means that when you log in it hashes your attempted password and compares the hash results. If your database is ever compromised no-one can see the actual passwords of it's users, only their hashes. By making the value of the hash MySQL stores one that is impossible to return(By claiming it's a 33byte value with the leading asterisk, then putting less than 33 bytes in as the value for example) you ensure that there is no way to log in as the intended user. – scragar Jul 03 '14 at 14:18
-
Interesting! Thank you for the explanation! – Sasha Grievus Jul 04 '14 at 08:12
2 Answers
1
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].

vaibhav
- 396
- 2
- 17
1
Use something like this
use mysql;
update user set user='admin' where user='root';
flush privileges;

user3244721
- 714
- 2
- 11
- 29