Support » Installing WordPress » Error Establishing Database connection.

  • I am trying to setup a blog site.

    I have the following setup on a SOLARIS BOX (Sparc 64 – Sun Blade 100)

    Apache 2
    Mysql 4.1.10 (max)
    PHP 5

    – Apache works , PHP pages show up
    -I ran all the tests “mysql-test-run” and everything was successful
    – I created a DB , USER successfully in mysql on my HOST
    $mysql -u wordpress -h blade -p
    password: *****

    It connects to the DB and when I do
    show databases;
    I see the database. Also when I say “use webpress;” it works;

    So when I setup the above DB values in “wp-config.php” and try to run
    It says cannot connect to the database.

    Any suggestions why it cannot connect through the PHP script/browser.

    BTW I am running the browser from a windows machine , connecting to my Sun machine but when use browser on the sun box the same thing. So i dont think its a browser or client/server issue.

    Is it a Permissions issue ? The mysql daemon is owned/run by root and the mysql directories are owned by root.


Viewing 15 replies - 1 through 15 (of 18 total)
  • Moderator James Huff


    Volunteer Moderator 🚀

    Hi macmanx,

    I checked and re-read the above suggested url’s and everything looks good.

    I even changed the php code (wp-includes/wp-db.php) where it actually connects to the database and have it print the DB parameters that it accepts from the wp-config file. now it prints the following message

    >>>>>> below indicates the <user><password><db><host> and its all correct.

    ———Cut here—–Browser—-Output———
    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at blade.

    ->>>>>>>>>>>>> wordpress, popomysql, wordpress, blade

    Are you sure you have the correct username and password?
    * Are you sure that you have typed the correct hostname?
    * Are you sure that the database server is running?

    If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    ———–Cut here——

    Now only thing it seems for me to do is debug wp-db.php. I would love to see any system error messages the code generates .


    These are the steps I took.

    1) Rebooted my sun box. This was not necessary but I wanted to start the mysql daemon manually and did not really want to kill the daemon.

    I had problems restarting the daemon. Apparently I did not have premissions to write to /usr/local/mysql/data directory. This dir was owned by root and mysql couldnt not write to it.

    So finally after changing the ownership to mysql I was able to manually start the daemon.

    2) Next i got this error when I try to run the following test php script

    $link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);
    if (!$link) {
    die(‘Could not connect: ‘ . mysql_error());
    echo ‘Connected successfully’;

    I get the following error
    ” Client does not support authentication protocol requested
    by server; consider upgrading MySQL client”
    This is my first installation and not upgrade. The version is Mysql 4.1.10
    I still went ahead and reset the password

    -> ‘some_user’@’some_host’ = OLD_PASSWORD(‘newpwd’);

    and now it works.

    so WORKS!!


    I follow your similar problem. But I am not able to fix. I am very new with PHP, Apache, MySql. I do little know with Unix Termial with my Mac OS X 1o.3.8 running PowerBook G4.

    I checked in Unix Termail window. cd /usr/local and then ls command that shows up php5 and mysql-standard-4.0.23-apple-darwin7.6.0-powerpc. And I don’t know where is apache I wish I know where but Mac OS X 10.3 has System Preference where I can go to Sharing and clicked Personal Web Sharing on that means Apache server power is turning on

    I tried with cd /usr/local/mysql/data permission denied. I can’t change How? Should I do?

    I experience same problem with Error establishing Database connection.

    I want to know where can I get database name, database username, database password. I did change my database. I did change from database username to Jamesrowe. And I changed from database name to Jamesrowe. I did save SAVE AS in wp-config.php

    The problem is still same again.

    I copy your script and save in test2.php and run www.******.net/~jamesrowe/test2.php

    I copied your scirpt and save in test2.php below

    $link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);
    if (!$link) {
    die(‘Could not connect: ‘ . mysql_error());
    echo ‘Connected successfully’;

    Browser show up below:

    Could not connect: Access denied for user: ‘mysql_user@localhost’ (Using password: YES)

    Any idea?


    ls -al /usr/local/mysql/

    check if you see 3’rd and 4’th columns are “mysql”. In your case they most likely are “root”.

    First of all you need to create a group “mysql” and also create a userid called “mysql” and mysql user should belong to mysql user.

    chown -R mysql:mysql /usr/local/mysql/data

    Hopefully this works for you on a Mac. I have never worked on Mac before but since you mention Mac OS X these unix commands should work.

    I tried following of your commands. Permission still denys. below you can see. I know /data is something I can’t allow because of root user right?

    Last login: Mon Feb 21 19:21:40 on ttyp1
    Welcome to Darwin!
    [PowerBook-G4:~] jamesrow% ls -al /usr/local/mysql/
    total 96
    drwxr-xr-x 19 root wheel 646 25 Dec 04:15 .
    drwxr-xr-x 14 root wheel 476 25 Dec 04:15 ..
    -rw-r–r– 1 root wheel 19099 18 Dec 13:46 COPYING
    -rw-r–r– 1 root wheel 5051 18 Dec 13:46 EXCEPTIONS-CLIENT
    -rw-r–r– 1 root wheel 8369 18 Dec 13:46 INSTALL-BINARY
    -rw-r–r– 1 root wheel 1937 18 Dec 10:25 README
    drwxr-xr-x 50 root wheel 1700 25 Dec 04:15 bin
    -rwxr-xr-x 1 root wheel 773 18 Dec 13:59 configure
    drwxr-x— 11 mysql wheel 374 21 Feb 09:41 data
    drwxr-xr-x 7 root wheel 238 25 Dec 04:15 docs
    drwxr-xr-x 53 root wheel 1802 25 Dec 04:15 include
    drwxr-xr-x 10 root wheel 340 25 Dec 04:15 lib
    drwxr-xr-x 3 root wheel 102 25 Dec 04:15 man
    drwxr-xr-x 10 root wheel 340 25 Dec 04:15 mysql-test
    drwxr-xr-x 3 root wheel 102 25 Dec 04:15 scripts
    drwxr-xr-x 3 root wheel 102 25 Dec 04:15 share
    drwxr-xr-x 31 root wheel 1054 25 Dec 04:15 sql-bench
    drwxr-xr-x 13 root wheel 442 25 Dec 04:15 support-files
    drwxr-xr-x 21 root wheel 714 25 Dec 04:15 tests
    [PowerBook-G4:~] jamesrow% chown -R mysql:mysql /usr/local/mysql/data
    chown: /usr/local/mysql/data: Permission denied
    chown: /usr/local/mysql/data: Operation not permitted
    [PowerBook-G4:~] jamesrow%

    You need to login as “root” and then only you can do chown as the files are owned by root.

    On a Mac you don’t usually have a root account. You normally run with root priveleges using sudo.
    Your command should be

    sudo chown -R mysql:mysql /usr/local/mysql/data

    Then you will be prompted for a password. It is your user password. If you are the admin of the machine you will already be in the list of users who can sudo. If not you will need to add your id to the sudoers file.

    Moderator James Huff


    Volunteer Moderator 🚀

    Just a small correction, all Macs running OS X have root accounts. Just login with the user name “root” and the administrator password you entered when either installing OS X or turning on your computer for the first time. However, John’s suggestion is far easier than logging in as root.

    By default, the root account is not available for login or su. You have to explicitly enable it using NetInfo Manager. Most administrators leave it off for security reasons since with sudo you are reminded each time you type a command that you have the potential to hose your system.

    Moderator James Huff


    Volunteer Moderator 🚀

    True, good point. But that doesn’t mean that they don’t have root accounts. It just means that they’re hidden.

    Moderator James Huff


    Volunteer Moderator 🚀

    Or, you could enable it by entering the following into the terminal:

    % dsenableroot -u username [-p ] [-r ]

    I was having this problem, searched in vain through all the threads. I checked my config since I have been using wordpress for awhile I figured it was not a config problem and was right. I also created this .php program to check to see if I could connect to my database and I could not.

    So the obvious was the answer. The database, as inferred in the error message was actually down. So, all I needed to do was wait for it to come back up.

    Sometimes, it’s the most obvious answer that is the answer. One thing was made glaringly obvious in my experience though. I know very little about wordpress, or .php. I probably know enough just to be dangerous.

    I’m having the same problem running

    So i tested this little script:

    $pipe = mysql_connect ($server, $user, $pass);
    echo $pipe;

    (replacing my own parameters of course)

    which returns a message I suppose is not what expected:
    “No input file specified.”

    btw I’m using server IIS, not Apache, running php 4.

    and i notice that the permission of my files and folders is: -rwxrwxrwx

    Any ideas? help will be appreciated.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Error Establishing Database connection.’ is closed to new replies.