The way in which your connecting per the information you provided those settings appear to be incorrect. Below I have provided the way in which you would connect via script and this also provides the exact settings as well.
https://support.hostgator.com/articles/how-to-connect-to-the-mysql-database (there is a wordpress example as well directly on this link for you)
Make sure your ‘localhost’ is also literally: ‘localhost’.
We do have support available 24 hours a day via live chat and telephone should you wish to connect with someone directly as well for further assistance.
Have a great day!