This article is half-done without your Comment! *** Please share your thoughts via Comment ***
When you install the MySQL, the root user is a default, and even most of the people also set the password ‘root’.
For MySQL, username and password like root-root is a very common so hackers can easily try this combination and can attack in your database system.
After the installation of MySQL Server, please don’t forget to rename the name of the root user.
In this post, I am sharing required steps for changing the name of the root user.
Connect MySQL and check the list of users:
1 2 3 4 5 6 7 8 |
mysql> select user,host from mysql.user; +------------------+-----------+ | user | host | +------------------+-----------+ | debian-sys-maint | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ |
Rename the ‘root’ user to ‘anvesh’:
1 |
rename user 'root'@'localhost' to 'anvesh'@'localhost'; |
Confirm the new user name:
1 2 3 4 5 6 7 8 |
mysql> select user,host from mysql.user; +------------------+-----------+ | user | host | +------------------+-----------+ | anvesh | localhost | | debian-sys-maint | localhost | | mysql.sys | localhost | +------------------+-----------+ |
Now, flush the privileges to make these changes happen:
1 |
FLUSH PRIVILEGES; |
Now, connect with new user name:
1 |
mysql -u anvesh -p |
Leave a Reply