WordPress.org

Ready to get started?Download WordPress

Forums

Error establishing a database connection under OS X 10.4.1 (26 posts)

  1. Paul
    Member
    Posted 9 years ago #

    Help! I've beed trying to install WP 1.5.1 on my local machine (Mac OS X 10.4.1) with no luck. I can't run install.php, I alwayd get... "Error establishing a database connection".

    Apache (default version), PHP (4.3.10), and MySQL (4.1.12) all seem to be installed and working properly. I have a database set up that I can access through "CocoaMySQL-SBG". I've set up wp-config.php with the name of the DB, user, and password, with host set to localhost.

    What am I doing wrong? Can anyone help?

  2. YellowSwordfish
    Member
    Posted 9 years ago #

    For starters this is a very good tutorial on setting up a local WP on a Mac. I used it with great success: http://maczealots.com/tutorials/wordpress/
    I had this problem and it was to do with changes to MySQL password hashing - if you look at the tutorial it is discussed in the comments. Might be the problem.... perhaps

  3. Michael Bishop

    Posted 9 years ago #

    Are you sure the database started up? When I recently installed mySQL, I couldn't get the database to start up, and not until I found this fix over at Mar Liyanage's site

    Database Re-Initialization

    Sometimes the scripts in the installer package do not work correctly, preventing the startup of the database server. Sometimes you need to reinitialize for other reasons, when the database is too screwed up. So if you have problems and you want a fresh start, perform these steps manually and then try again to start the server:

    1. sudo find /usr/local/mysql/data -type f -exec rm {} ';'
    2. sudo hostname 127.0.0.1
    3. cd /usr/local/mysql
    4. sudo ./scripts/mysql_install_db
    5. sudo chown -R mysql data/

    Note that you will loose all data stored in the database this way.

    was I able to get the database going, and finish the install.

  4. Paul
    Member
    Posted 9 years ago #

    Thanks for the suggestions. I've gone through the tutorials, re-initialized the database, and tried all the other scripts... no help. I can see in the terminal that my password is being accepted and MySQL is using the correct database, but nothing happens !?!

    mysql> u wordpress
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> r
    Connection id: 8
    Current database: wordpress

    FYI... with this version of MySQL they have provided an OS X Pref Pane for starting and stopping the server. I've stopped / started through the pref pane and through the terminal.

    Anyone have any ideas?

  5. Michael Bishop

    Posted 9 years ago #

    Sorry, best I've got.

  6. Paul
    Member
    Posted 9 years ago #

    PROBLEM SOLVED. :)

    So I tried reinstalling MySQL 4.1.12 several times to make sure something didn't happen during installation... it didn't work!

    I then completely uninstalled MySQL 4.1.12 and installed MySQL 4.0.24. Now everything works!:)

    There is a great script for uninstalling MySQL at http://www.entropy.ch/software/macosx/mysql/remove-old-mysql.html

    The tutorial (and comments) mentioned earleir is also extremely helpful ... http://maczealots.com/tutorials/wordpress/#comment22

    Thanks miklb & YellowSwordfish

  7. mtbikemj
    Member
    Posted 9 years ago #

    I have the same problem, but I'm using Mac OS X Server 10.4.1. I'm using MySql server version: 4.1.10a that came with the O/S. Any idea how I can get wordpress to work? Thanks!

  8. iand
    Member
    Posted 9 years ago #

    Maybe you are having authentication protocol problems. See here.
    I used the following from that page:
    mysql> SELECT Host, User, Password FROM mysql.user
    -> WHERE LENGTH(Password) > 16;

    Followed by
    mysql> SET PASSWORD FOR
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');

  9. mtbikemj
    Member
    Posted 9 years ago #

    I just tried that, I still get the "Error establishing a database connection" page. I can connect to mysql with the same username and password from command line and from aqua data studio.

  10. iand
    Member
    Posted 9 years ago #

    Are you sure you have wp-config.php correct? Using root and localhost? Mine is
    define('DB_NAME', 'dbnamehere'); // The name of the database
    define('DB_USER', 'root'); // Your MySQL username
    define('DB_PASSWORD', 'passwordhere'); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

  11. mtbikemj
    Member
    Posted 9 years ago #

    I used a differnt user, but I'll give root a shot.

  12. mtbikemj
    Member
    Posted 9 years ago #


    define('DB_NAME', 'wordpress');
    define('DB_USER', 'root');
    define('DB_PASSWORD', 'pa55w0rd');
    define('DB_HOST', 'localhost');

    imac:/ mj$ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 9 to server version: 4.1.10a

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> use wordpress;
    Database changed
    mysql>

    I have a feeling there is a problem with the 4.1.10a. I had problems in the past with MT running on my Xserve.

  13. Michael Bishop

    Posted 9 years ago #

    If you use a different name, be sure you set that user up in the mysql DB for your wp DB.

  14. Paul
    Member
    Posted 9 years ago #

    I would suggest unintalling 4.1.10a and installing 4.0.24. See my comment above that starts with "PROBLEM SOLVED".

  15. mtbikemj
    Member
    Posted 9 years ago #

    Look what I found:
    http://docs.info.apple.com/article.html?artnum=301457

    When running MySQL and PHP on the same Mac OS X 10.4 server, you may find that PHP cannot connect to MySQL. When PHP is communicating with a MySQL server on the same host, it uses a socket file to communicate, and looks for it at /tmp/mysql.sock. On Mac OS X Server 10.4, MySQL creates this socket file at /var/mysql/mysql.sock.

  16. YellowSwordfish
    Member
    Posted 9 years ago #

    Just for the record I am using 4.1.11 and OSX 10.4.1 and all works just fine and first time except for the password I mentioned before). I know this comment doesn't help but I don't see that reverting to older versions is necessarily the answer - even if it does resolve the overall situation. Having said that, I am running it on a Powerbook....

  17. mtbikemj
    Member
    Posted 9 years ago #

    I'm still not having any luck. Apple has not got back with me yet. I"ll post on here if I find anything.

  18. Michael Bishop

    Posted 9 years ago #

    http://forums.macosxhints.com/index.php
    try over there. Those guys are brilliant when it comes to get under the hood of OS X.

  19. mtbikemj
    Member
    Posted 9 years ago #

    I reinstalled OS X Server 10.4.1 fresh, updated it, started the web server, enabled PHP, installed MySql from the Mac GUI tool that comes with OS X Server, created the database, created the users, and I still have the same Error establishing a database connection problem. :(

  20. Try following this guide: http://maczealots.com/tutorials/wordpress/

  21. iVoltage
    Member
    Posted 9 years ago #

    I just posted a possible for OS X Server users on Mac OS X Hints

    http://forums.macosxhints.com/showthread.php?p=216582#post216582

    Hope it helps!

  22. mtbikemj
    Member
    Posted 9 years ago #

    That worked! Thanks iVoltage!

  23. tanabb
    Member
    Posted 8 years ago #

    I've had this same "Error establishing a database connection" problem and finally solved it with the help found at

    http://wordpress.org/support/topic/59700

    In the wp-config.php file I've changed the line:

    define('DB_HOST', 'localhost');

    by:

    define('DB_HOST', '127.0.0.1');

    and it worked!!!

    thanks a lot to the WordPress support!
    :)

  24. scottbruin
    Member
    Posted 8 years ago #

    tanabb,

    thanks for that!

    changing localhost to 127.0.0.1 solved the problem!

  25. lylegunderson
    Member
    Posted 7 years ago #

    Chalk up one more user whose problem was solved by using the IP address instead of localhost. Thank you for sharing your solution!

  26. marsopa
    Member
    Posted 7 years ago #

    tanabb thanks also from me. Just change localhost for 127.0.0.1 in wp-config.php and all works fine

Topic Closed

This topic has been closed to new replies.

About this Topic