Forums

[resolved] Error establishing a database connection on OS X 10.5 (8 posts)

  1. jonokane
    Member
    Posted 2 months ago #

    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!

  2. jonokane
    Member
    Posted 2 months ago #

    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
  3. thesheep
    Member
    Posted 2 months ago #

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

  4. breakthruhere
    Member
    Posted 2 months ago #

    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!!!!""

  5. breakthruhere
    Member
    Posted 2 months ago #

    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 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"

  6. alui
    Member
    Posted 3 weeks ago #

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

  7. mrogers
    Member
    Posted 3 weeks ago #

    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.

  8. brianmhull
    Member
    Posted 2 days ago #

    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.

Reply

You must log in to post.

About this Topic