use 127.0.0.1 instead of localhost for db host parameter

localhost means connect via socket, which is in some cases not available
or wrong configured or differs from the place php assumes it.