I created a new mysql user with all the same privileges as the current 'root' user. For security reasons I thought why not create another user for this so people at least won't know the username of my super user.

I then dropped the root user.

Immediately my DB started throwing connection refused errors for all of my other users.

I quickly recreated the original 'root' user and everything magically started connecting again.

My question is then, is it possible to delete the root user in a MySQL database? And if so how?



All other security options are in place. We are not just securing our system by trying to remove the root user. We have some over zealous security people here and removing the MySQL root user was just an extra step.

I agree with @Pleun for the reasons I tried to remove it.

  • 7
    Security through obscurity is not security at all... – Platinum Azure Jul 23 '13 at 20:59
  • 1
    Were all your other users connecting as root? – Bill Karwin Jul 23 '13 at 21:01
  • 1
    @Pleun: On what grounds? – Platinum Azure Jul 23 '13 at 21:02
  • 2
    Just choose a really strong (long) password for your root user. That should be safe enough. – mata Jul 23 '13 at 21:18
  • 1
    I'm saying that deleting the MySQL 'root' user does not make other users unable to connect. I just tested this to confirm it. So I conclude that your users were trying to connect as the MySQL 'root' user, but couldn't after you deleted that user. – Bill Karwin Jul 25 '13 at 0:19

You can rename the 'root' user.

To rename the administrator’s username, use the rename command in the MySQL console:

mysql> RENAME USER root TO new_user;

The MySQL “RENAME USER” command first appeared in MySQL version 5.0.2. If you use an older version of MySQL, you can use other commands to rename a user:

mysql> use mysql;

mysql> update user set user=”new_user” where user=”root”;

mysql> flush privileges;

From here.

  • @user1819471 , What solution did you implement? – Kreya Aug 10 '20 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.