This question already has an answer here:

I have created a Ubuntu 18.01 droplet on digital ocean. while creating droplet I opted for one click LAMP installation.

Therefore I got mysql pre-installed. Now I am able to login as root by using a blank password. For example mysql -u root -p . when it prompts for password. then It accepts whatever I enter there.

I want to set a password for root user and one should be able to login only with this password.

I've tried running sudo /usr/bin/mysql_secure_installation But in this script, there was no option to disable this feature.

marked as duplicate by Melebius, karel, Fabby, Eric Carvalho, abu_bua Nov 26 '18 at 18:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.