WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error establishing a database connection (6 posts)

  1. butterman
    Member
    Posted 7 years ago #

    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?

  2. MichaelH
    Member
    Posted 7 years ago #

    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

  3. butterman
    Member
    Posted 7 years ago #

    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?

  4. MichaelH
    Member
    Posted 7 years ago #

    Sorry--here's the full link:
    http://codex.wordpress.org/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.

  5. MichaelH
    Member
    Posted 7 years ago #

    Looks like a file called

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

    holds the database information.

  6. butterman
    Member
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags