Support » Installing WordPress » Error establishing a database connection under OS X 10.4.1

  • 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?

Viewing 15 replies - 1 through 15 (of 25 total)
  • For starters this is a very good tutorial on setting up a local WP on a Mac. I used it with great success:
    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

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

    Thread Starter Paul


    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?

    Sorry, best I’ve got.

    Thread Starter Paul



    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

    The tutorial (and comments) mentioned earleir is also extremely helpful …

    Thanks miklb & YellowSwordfish

    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!

    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
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');

    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.

    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

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

    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

    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.

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

    Thread Starter Paul


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

    Look what I found:

    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.

    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….

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