• Resolved butterman

    (@butterman)


    In installed WordPress on my home server about a week ago with no trouble. I had Gallery2 installed and working on the same server. After the WP installation, I could not access Gallery2 (access denied error). To access Gallery2, I entered the following command:

    $ mysql gallery2 -uroot -e"GRANT ALL ON gallery2.* TO username@localhost IDENTIFIED BY 'password'"

    Gallery2 is now working, but WP is broken. WP says:

    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 localhost. This could mean your host's database server is down.

    How do I access my blog (which has content I want to keep) without breaking Gallery2 again? Can I use the same mysql username and password for both installations?

Viewing 5 replies - 1 through 5 (of 5 total)
  • There’s no reason WordPress can’t share a MySQL database with any other software that uses MySQL. Make sure you have the correct data in wp-config.php.

    wp-config.php has a $table_prefix that you can use to insure database tables names don’t conflict with other software (including other copies of WordPress).

    Other resoureces:
    Creating a database and user (from Installing WordPress)
    Editing wp-config.php

    Thread Starter butterman

    (@butterman)

    The first of the two links in the previous post is broken. I found two copies of wp-config.php:

    /etc/wordpress/wp-config.php
    /usr/share/wordpress/wp-config.php

    Many of the entries referred to in the second link are entirely missing from my copy of wp-config.php. Here’s my config.php:

    <?php
    /** WordPress's Debianised default master config file
    Please do NOT edit and read about how the configuration works in the README.Debian
    **/
    
    require_once('/etc/wordpress/config-'.strtolower($_SERVER['HTTP_HOST']).'.php');
    
    define('ABSPATH', '/usr/share/wordpress/');
    
    require_once(ABSPATH.'wp-settings.php');
    ?>

    Do I have the right file? Why does it tell me not to edit?

    Sorry–here’s the full link:
    https://codex.www.ads-software.com/Installing_WordPress#Step_2:_Create_the_Database_and_a_User

    Okay — looks like the Debianized version of wordpress has a separate configuration file. I’ll have to look for that–maybe someone else knows about that.

    Looks like a file called

    /etc/wordpress/config-'.strtolower($_SERVER['HTTP_HOST']).'.php');

    holds the database information.

    Thread Starter butterman

    (@butterman)

    Problem solved. I found the configurate file with my database information in it. The database password was not one that I set, but rather some strange mix of numbers and letters–apparent automatically generated. I replaced that password with my password and WordPress came back up with everything intact. Not sure why my password changed. Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.