WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error establishing a database connection (7 posts)

  1. AcousticBlue
    Member
    Posted 5 years ago #

    OK, I know this post has been made 1000x probably, but I cannot find a search function for this forum...and, well, I think I've tried everything I can find to fix this.

    Anyway, I am sure my name/pass/db name are correct in the install.php file. Additionally, I am almost certain that localhost is correct for the Host...

    I am running Apache on Mac OS X.5.6 Server. Additionally, I am using MAMP for mySQL and PHP...

    So far I have tried capitalizing Localhost, changing the socket info in the mySQL_socket in the php.ini file to tmp/mysql.sock and var/mysql/mysql.sock, I have tried using localhost:portnum, and I have tried using the SQL command OLD_PASSWORD with my wordpress user. All to no avail. Are there other possibilities that could be causing this?

    Please, this is driving me nutz!!! ;)
    Thanks in advance,

  2. MichaelH
    Member
    Posted 5 years ago #

    This search:
    http://www.google.com/search?q=wordpress+++WordPress+›+Support+»+Installation++Error+establishing+a+database+connection+mamp

    found, among others, this:
    http://foolswisdom.com/mac-wordpress-error-establishing-a-database-connection/

    Please let us know what solves your problem.

    Note: the search for the forums is just above the Download tab at the top of my screen.

  3. AcousticBlue
    Member
    Posted 5 years ago #

    Thanks for the search info...

    Ok, this was FINALLY resolved with another solution I finally found in only one place. Here it is...

    For the Host, you have to put localhost:/Applications/MAMP/tmp/mysql/mysql.sock

    I.e, for the port, put the path to the socket...no idea why this one thing works...

    thanks all,

  4. Lloyd Budd

    Posted 5 years ago #

    AcousticBlue, thanks for sharing the solution!

    Yeah, my foolswisdom post is not for MAMP.

    Your solution suggests that you could also solve it be updating php.ini:
    mysql.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock

    That is probably a better solution as it should fix all PHP/MySQL apps.

    There is another solution at http://www.fischerlaender.net/apple-mac/mac-os-x-trouble-with-mamp-mysql

  5. freeinn
    Member
    Posted 4 years ago #

    None of these worked for me... Does anyone have a better solution. I still cannot connect to database: Error establishing a database connection.

    My dbname, username and password are ok. But with local host I have problems

    I already tried all of the above mentioned solutions and the following localhost names:

    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    /** MySQL hostname */
    define('DB_HOST', 'localhost:8889');
    /** MySQL hostname */
    define('DB_HOST', 'Localhost');
    /** MySQL hostname */
    define('DB_HOST', 'Localhost:8889');
    /** MySQL hostname */
    define('DB_HOST', '/tmp/mysql.sock');
    /** MySQL hostname */
    define('DB_HOST', '/Applications/MAMP/tmp/mysql/mysql.sock');
    /** MySQL hostname */
    define('DB_HOST', 'Localhost:8889');

    I'm really puzzled :-(

  6. freeinn
    Member
    Posted 4 years ago #

    ...and of course
    define('DB_HOST', 'localhost:/Applications/MAMP/tmp/mysql/mysql.sock');

    didn't also work.

  7. freeinn
    Member
    Posted 4 years ago #

    After the whole night (in the morning) find out that I was editing the wrong file...
    Dumb us me.

    Now it's all working fine and it wasn't the problem in the first place.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.