Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock

After completing the MariaDB 10.2 Installation by using below command

# sudo yum install MariaDB-server MariaDB-client

I tried to run below command to run secure installation.

# sudo mysql_secure_installation 

but kept getting error "Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")"

As per error, I tried to find the file in /var/lib/mysql/mysql.sock but could not find. Looked into my.cnf and many other files but could not solve it. Finally notice that I did not start the Mysql (MariaDB) service.
Once MariaDB service was started. It created the mysql.sock file in var/lib/mysql/my direcoty and was able to run secure installation.