In some cases it is bcz of your sql server is not on localhost and you use localhost to connect mysql database.I have done that sir, using inmotionhosting VPS managed hosting, tried 2 databases still same issue. @Masoom Xmeer @SergKUBik @andersonkida
Open your phpmyadmin and what is written on the top corner? localhost or anything else?