Unable to secure MySQL on fresh LEMP droplet

Posted October 20, 2018 1.4k views
MySQLUbuntu 18.04

When ssh into the droplet as root, I am able to just type mysql and launch MySQL anonymously.

I then exited, and ran mysql_secure_installation, and followed all the prompts to remove the anonymous user, and set a root password.

I then stopped mysql using /etc/init.d/mysql stop and started it back up again /etc/init.d/mysql start

I then typed mysql again, and was still able to have full access to mysql anonymously as the root OS user. I expected to be denied access.

Keeping mysql running, I ran mysql_secure_installation again, and was NOT prompted to enter my current password.

Stopping mysql and then running mysql_secure_installation, I WAS prompted to enter my current password, but because the service had been stopped, it was not able to do anything.

What am I doing wrong?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Running the mysql command alone as root sources the file /root/.my.cnf, which might contain the actual login/password. So check inside that file for possible credentials.