WordPress.org

Ready to get started?Download WordPress

Forums

Error Establishing Database connection. (19 posts)

  1. rprajapa
    Member
    Posted 9 years ago #

    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
    http://rprajapa.*****.com/blog/wp-admin/install.php
    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.

    Thanks,
    Rakesh

  2. rprajapa
    Member
    Posted 9 years ago #

    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 .

  3. rprajapa
    Member
    Posted 9 years ago #

    PROBLEM SOLVED.

    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

    <?php
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>

    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

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

    and now it works.

    so http://192.168.0.200/blog/wp-admin/install.php WORKS!!

    Thanks

  4. appleboy
    Member
    Posted 9 years ago #

    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.

  5. appleboy
    Member
    Posted 9 years ago #

    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

    <?php
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>

    Browser show up below:

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

    Any idea?

  6. rprajapa
    Member
    Posted 9 years ago #

    Try

    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.

  7. appleboy
    Member
    Posted 9 years ago #

    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%

  8. rprajapa
    Member
    Posted 9 years ago #

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

  9. JohnScarry
    Member
    Posted 9 years ago #

    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.

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

  11. JohnScarry
    Member
    Posted 9 years ago #

    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.

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

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

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

  14. jimgleeson
    Member
    Posted 8 years ago #

    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.

  15. laslo
    Member
    Posted 8 years ago #

    I'm having the same problem running
    http://www.imaginaccion.net/cinencuentro/wp-admin/install.php

    So i tested this little script:

    <?php
    $server='localhost';
    $user='inspers_minh';
    $pass='your-password';
    $pipe = mysql_connect ($server, $user, $pass);
    echo $pipe;
    ?>

    (replacing my own parameters of course)
    http://www.imaginaccion.net/cinencuentro/test/test.php

    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.

  16. moshu
    Member
    Posted 8 years ago #

    I don't know anything about IIS - but a search probably would bring up a lot of topics; many people had problem with installing.

    If you have the WP in "cinencuentro" folder, why are you testing it in a folder below? > cinencuentro/test ?

    EDIT. Posting the same question in multiple threads just will confuse the potential helpers and might result ingnoring your questions...

  17. laslo
    Member
    Posted 8 years ago #

    ok, sorry for posting that twice.

    I did check the 4 parameters in the wp-config file. Although i'm not sure about the last one:

    define('DB_HOST', 'database'); // 99% chance you won't need to change this value

    they say dont change it, but in other examples I've seen that people use an IP address, plus a port number. I also tried using the IP number where my DB is and the port 3306 which is the one that use MySQL Administrator, which btw can connect without any problem to the DB.

    the 'test.php' script is a separated php. I just tried it to see if i could connect using that bit of code. and I couldnt. I also tried:

    <html>
    <head>
    <title>Ejemplo de PHP</title>
    </head>
    <body>
    <?php echo "Hola mundo"; ?>
    </body>
    </html>

    getting the same response: "No input file specified."

    I guess that means there's something wrong with IIS and the way it manages PHP.
    Which is confusing because when i try http://www.imaginaccion.net/cinencuentro/wp-admin/install.php
    I got the error page of WP, but it's still a HTML page built with PHP, my guess then was that PHP worked. now I realize I can't even run a "hello world" script...

    Should i need to use Apache instead of IIS?

  18. moshu
    Member
    Posted 8 years ago #

    As far as I know there are many users running WP on IIS - but as I said, I am not a server expert.
    Based on what I can see when clicking on the install link you've posted above I would say PHP is running (otherwise there would be just code gibberish), you just have to figure out what the 4 pieces of info are. Is it hosted by yourself or is it a hosting company? In the latter case they should be able to tell you exactly what the needed info is.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.