• Anyone come across this:

    WordPress can’t connect to its database when the host name is set in wp-config to the default ‘localhost’.

    However, I can connect to the MySQL server with that host name and the same username/password on the same machine, using both Sequel Pro and MySQL Administrator, so I know the database server is running, and the user details are correct.

    If I change the hostname in the config file to ‘127.0.0.1’, WordPress can connect to the database, and everything appears to be working OK, except that when I look at the WordPress blog on another machine, a lot of the links to files appear to be broken. I see the blog front page, for example, but the CSS stylesheet[s] are not linked properly, so I just see the raw unstyled HTML. All the text links on the page appear to point to ‘http://127.0.0.1/……’

    Any idea what might be going wrong? I imagine the two issues are linked, but maybe they aren’t…

    My test machine (the blog will eventually be moved to a dedicated server):

    MacBook Pro
    MacOS 10.5.7
    MySQL 5.1.36 (x86 64bit, from MySQL.com)
    PHP 5.2.8 (Apple standard install)

    Alex
    Goldsmiths University of London
    London UK

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Unable to connect to database using localhost’ is closed to new replies.