Just installed mysql on Ubuntu -

sudo apt-get install mysql-server
sudo apt-get install mysql-client

As part of the installation process, I provided a password for the root user.

I can now log in with

mysql -u root -p

But I'd love some other user besides root to own the mysql administration. I'm coming over from the world of Postgres and have never used MySQL before, so I'm wondering how I could change this user.



This is based off a recommendation from the Wordpress installation guide:

It is a safer practice to choose a so-called "mortal" account as your mysql admin, so that you are not entering the command "mysql" as the root user on your system. (Any time you can avoid doing work as root you decrease your chance of being exploited.)

1 Answer 1


Connect to MySQL as -u root, then

First, see what root has:


Then add a new user, similar to the root:

GRANT ALL PRIVILEGES ON *.* TO 'foobar'@'localhost' IDENTIFIED BY ('long secure pwd') WITH GRANT OPTION;

where foobar is the "mortal" mentioned in your quote.

Then re-login as foobar to verify it. Then get rid of root (or at least emasculate it). Perhaps this

REVOKE ALL *.* FROM root@localhost;

Then verify with

SHOW GRANTS FOR root@localhost;
SELECT user, host FROM mysql.user WHERE user = 'root';

The first should show only GRANT USAGE, which lets root in, but without any privileges. The second checks to see of root can get in from any other "host". If there are any ways in, we can discuss zapping them.

  • I chuckled at the use of "emasculate". Sorry for being a bit dense - but how do I "get rid of root" in mysql? Commented Sep 2, 2017 at 22:07
  • Forum users need a chuckle now and then. I added more specifics.
    – Rick James
    Commented Sep 2, 2017 at 23:11
  • @RickJames are you 100% sure that renaming root user doesn't break something else in MySQL? For a shared hosting env renaming root is a good security principle.
    – Sybil
    Commented Sep 3, 2017 at 5:05
  • @FyodorGlebov - Not sure. It could be that the hosting env uses root for admin purposes. And any other 3rd party software. So... Be ready to jump in with your new SUPER user and re-establish root.
    – Rick James
    Commented Sep 3, 2017 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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