With a fresh (but old) install of Ubuntu and MySQL, I found I could access the MySQL via command line client without being asked for any user or password.
This bothered me as the default situation, and I tried to investigate it. Logging in as root required the root password. But logging in without specifying the user (ie, just typing mysql on the command line) asked me for neither user nor password.
I think I've tracked it down to the user debian-sys-maint, which appears to have full MySQL permissions on the one hand, and is also the default client user as defined in /etc/mysql/debian.cnf on the other.
My first instinct was to get rid of the user entirely, because this seemed a security hole to me, but upon reading up, including the posts linked below, it seems that debian-sys-maint is needed.
So my plan is to try the following:
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'debian-sys-maint';
GRANT RELOAD on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'xxxxxx';
FLUSH PRIVILEGES;
Can anyone comment on this as the recommended / expected / correct way to secure a default MySQL installation?
Should I also alter /etc/mysql/debian.cnf to remove this section?
[client]
host = localhost
user = debian-sys-maint
password = xxxxxx
socket = /var/run/mysqld/mysqld.sock
(It does warn: # Automatically generated for Debian scripts. DO NOT TOUCH!)
I intend to replace it with my own ~/.my.cnf client section anyway.
Update:
The permissions on /etc/mysql/debian.cnf are:
-rw------- 1 root root 312 2012-05-20 23:07 /etc/mysql/debian.cnf
References:
sudo. I logged into MySQL from a regular account, without being asked user / password. I believe that it was thedebian-sys-maintuser that I was going in as. – Stewart Aug 12 '14 at 04:22select user()and found it may not be anything to do withdebian-sys-maintat all. Apparently I'm logging in asstewart@localhost- but there is no userstewartin the tableuser. I do not understand this at all. – Stewart Aug 12 '14 at 04:33information_schema. But the point is, why does the user exist? I thought MySQL users were separate from OS system accounts. – Stewart Aug 12 '14 at 07:21debian-sys-maintis used when shuting down the server and checking that there are arootuser in MySQL when starting MySQL and other stuff. Don't remove it, but protect the file and your ordinary accounts with good passwords or even better, with SSH key login and disable login with passwords in `ssh – Anders Jan 02 '15 at 04:50/usr/share/doc/mysql-server-5.5/README.Debian.gzfor more information that any MySQL administrator on a Debian or Debian based system should know. – Anders Jan 02 '15 at 04:53