Never mind. I solved it by myself today. but for the benefit of others who might stumble upon the same problem, here is what I did.
First I uninstalled mariaDB.
#yum remove mariadb-server
I had reinstalled mariadb like 5 times! However this time I tried removing all the libraries.
#yum remove mysql-server mysql-libs mysql-devel mysql*
Then all I did was reinstall mariadb agin. Everything has been working fine ever since.