I just installed MySQL (Ver 14.14 Distrib 5.7.22) on Ubuntu 18.04 and I discovered something weird:
I installed MySQL and used mysql_secure_installation
to set a password for root, but as soon as I am logged in SSH with any user with sudo-rights, I can simply access MySQL without being prompted to enter a password via mysql -u root
or via mysql -u root -p
& simply clicking ENTER (when asked "Enter password:").
Is this normal?
I know from prior versions that I always had to enter a password when I wanted to access MySQL, even with sudo.
Best Answer
Ubuntu's MySQL packages (which are based on Debian's) use by default the
auth_socket
plugin. With this plugin when connecting from the local machine no password is required, but the server identifies the operating system user and matches that user. So if you are root on the system and login you become root. This avoids having to setup a MySQL root password first.See also https://wiki.debian.org/MySql