Just spent 30 minutes fighting the magento GUI installer, which kept giving me a ‘unable to connect to database’ error. Only after trying a multitude of config permutations did I realize that I had to put a valid hostname (not localhost) into the hostname textbox (even though I could connect to localhost via command line). Before entering a hostname into the textbox, be sure the hostname is in accessible (either via DNS or /etc/hosts). Good luck.