Securing your database server is mandatory one if you consider the data should be protected, The overarching theme of securing MySQL (and almost any other system) is that access should be granted only when absolutely necessary. Your data safety sometimes comes down to a balance between convenience and security.
Sometime the simple script mysql_secure_installation will not secure the database server in that case we can fix that in below method.
First Login to MySQL/MariaDB shell
sudo mysql -uroot -p (hit enter button)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
flush privileges;
quit;