Support » Installing WordPress » Error establishing a database connection on OS X 10.5

  • Resolved jonokane

    (@jonokane)


    Hello All,
    First, I have done a ton of searching on this topic and I see that I’m not the only one having issues. Unfortunately, I have spent far too much time on this and I’m still scratching my head.

    I am using a fresh install of OS X Leopard, I have PHP 5.2.4 running, MySQL 5.0.51a MySQL Community Server running on top of OS X’s pre-installed Apache. I can parse PHP, and I can connect to my local MySQL server via command line. I installed phpMyAdmin, and that’s running smoothly locally as well (phpMyAdmin is able to connect read/write to/from MySQL).

    I keep getting the “Error establishing a database connection” page when I hit my local wp site. I have a fresh install of WordPress, with a double-triple-checked wp-config.php file. Configured as follows:

    define('DB_NAME', 'dbname');    // The name of the database
    define('DB_USER', 'root@localhost');     // Your MySQL username
    define('DB_PASSWORD', 'xxx'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this valu

    e

    I tried changing the ‘DB_HOST’ designation to my machine’s IP, this did not work as well.

    I have also re-assigned the mysql.default_socket php.ini:
    mysql.default_socket = /tmp/mysql.sock

    Additionally, the my.cnf file:

    [mysqld]
    socket=/var/mysql/mysql.soc

    I have tried restarting all services, re-installing all services (besides apache), and, well, I’m starting to lose hope! I have done wp installs a gazillion times, but never ever had an issue like this!!!! Someone please help! Any smart suggestions are greatly appreciated!

Viewing 15 replies - 1 through 15 (of 21 total)
  • Followup: After spending what seems like an absolutely ridiculous amount of time on this, I have figured out the embarrassingly simple issue.

    localhost != Localhost

    My Mac identifies itself as Localhost, NOT localhost! Learned something extremely obvious…. 🙂

    So the config should look like this:

    define('DB_NAME', 'dbname');    // The name of the database
    define('DB_USER', 'root');     // Your MySQL username
    define('DB_PASSWORD', 'xxx'); // ...and password
    define('DB_HOST', 'Localhost');    // 99% chance you won't need to change this value

    Thanks. I just got stuck on the same thing and your post saved me.

    Wow! Same problem here… I wasted hours on this. Id like to know where the problem lies… One small capitalisation of a letter in the code for the latest release? or a problem with 10.5?

    jonokane, how did you find out?

    Quote: “99% chance you won’t need to change this value”

    More like: “100% chance you will do youre head in trying trying to figure out why your machine wont respond to the the host name “localhost!!!!””

    I did some further testing regarding this issue as follows…

    Im hoping that this isnt a problem with apache. Ive done a bit of checking into my config files and all seems to be normal. (This is starting to bore me why the hell it works with a capital L.

    It seems it must be a problem with the code as I can connect to the target database with the same user name.

    1. Make a clean install of the wordpress-2.3.3.tar that I downloaded from http://www.wordpress.org

    2. Copy the files to a new subdirectory to compare with my working install

    3. Go through all the default files checking for any caps mistakes

    Ive tried both solutions with a clean and modified db (sql dump) from a previous install that worked no prob with the host name “localhost” not “Localhost”

    you saved my day after wasting HOURS on this type-case problem! thanks so much!

    Thanks for posting this! The same problem was driving me insane too. I never would have thought to change the name to a capital ‘L’.

    This is definitely a bug in WordPress 2.5, because every other web app I have running on this machine uses “localhost” and it connects to the MySQL server just fine.

    Man I poured over this for hours before finding this post. A local install on 10.4 was so easy, but 10.5 has been a nightmare. Glad to have found a good resources for 10.5 here.

    Thanks.

    heyitsgarrett

    (@heyitsgarrett)

    Good lord! Thanks for this post. That was the problem with mine too. I was so confused.

    BradBrand

    (@bradbrand)

    Great $DIETY in $AFTERLIFE

    You probably saved me a grand in monitor damage and a couple grand more in emergency room bills. I never woulda figured this one out.

    Many thanks.

    jonokane-karma += 10

    ckuettner

    (@ckuettner)

    Here too, I lost too many hours on it… Thanks for resolving this!!!

    but I use Mac OS X 10.4, so this can’t be a Leopard-only problem.

    I tried several WP versions so this is also not WP-version specific.

    And, yes, all the other web-apps successfully connected to MySQL.

    Anonymous

    Silly. Thanks for the post. Hope it gets fixed soon.

    searchen

    (@searchen)

    Am sitting with the same issue, but it is not saved by the capitalization of ‘localhost.

    Yesterday, I was unable to connect to the online-server (I somehow hot into a loop, and instead of displaying the front end, the link redirected to index.html).

    I actually have a site running successfully on a subdomain, and have other blogs all going fine on the same server. All with same version 2.5.1 and similar setup. This is voodoo.

    I have tried the same as suggested above, with new database, clean install, and still no luck.

    I am using WP 2.5.1, and am mega frustrated. The backend seemed to work OK with the old database, but wasn’t fixing permalinks properly.

    Yikes…

    Lloyd Budd

    (@lloydbudd)

    This isn’t a WordPress issue, but a Mac issue. The correct solution is to set mysql.default_socket = /tmp/mysql.sock in /etc/php.ini.

    Details at http://foolswisdom.com/mac-wordpress-error-establishing-a-database-connection/

    damassipappas

    (@damassipappas)

    MY GOD!!!

    This needs to be stuck to the top!!! I was about to throw my computer out the window!!

    Hello my site ( http://www.problemcocuk.com ) have this problem. How can I optimize to mysql?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Error establishing a database connection on OS X 10.5’ is closed to new replies.