UPDATE**
I have solved the issue.
For others who might face the same problem, I have solved it by removing the socket line in /etc/odbc.ini in
Socket = /run/mysqld/mysqld.sock
Also, replaced localhost with the IP address to connect through it. I used localhost IP 127.0.0.1
Server = 127.0.0.1
Don’t forget to reboot your machine,
I would like to mention this post as a reference as well
Reference post
Thanks to erichowey
Everything worked fine for now.
Thanks