0

I just installed MySQL on Debian 6.

With PHPMyAdmin I noticed there are already 4 MySQL users:

debian-sys-maint (localhost)
root             (127.0.0.1)
root             (localhost)
root             (myhostingcompanyurl)

Are all of those necessary?

Jeff Widman
  • 2,285
  • 3
  • 22
  • 20
dynamic
  • 730
  • 6
  • 17
  • 31

1 Answers1

2

The answer is "sort of". The debian-sys-maint one is definitely necessary, Debian uses it to perform automatic maintenance like rotating logs.

The three different root accounts are because MySQL treats your host address as part of your account, so even with the same username, you might get a different account depending on how you connect.

'root'@'localhost' is an account using "root" as their username who connects to MySQL via the socket file (eg /var/run/mysqld/mysqld.sock).
'root'@'127.0.0.1' is an account using "root" as their username who connects via TCP/IP coming from the 127.0.0.1 IP address.
'root'@'myhostingcompanyurl' is an account using "root" as their username who connects via TCP/IP coming from an IP address that reverse-resolves to myhostingcompanyurl.

If you don't want to have different permissions for people calling themselves root depending on how they connect to the server, you could create a 'root'@'%' account, where % will match any connection's hostname, keeping in mind that you lose security in the case that 'root'@'someforeigncountry' figures out how to connect. Then you could remove the three specific accounts.

You can find out more about how accounts are made up of usernames and hostnames in the mysql documentation here, and the "special meaning" of localhost here.

DerfK
  • 19,313
  • 2
  • 35
  • 51
  • 1
    Also note that even if you use 'root'@'%', you still need a separate 'root'@'localhost' if you want to connect through the socket. – Brian Feb 10 '11 at 00:51
  • Read `/usr/share/doc/mysql-server-5.5/README.Debian.gz` for more information that any administrator on a Debian based system should know about MySQL. – Anders Jan 02 '15 at 04:54