Ready to get started?Download WordPress


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

  1. butterman
    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
    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
    Posted 7 years ago #

    The first of the two links in the previous post is broken. I found two copies of 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:

    /** WordPress's Debianised default master config file
    Please do NOT edit and read about how the configuration works in the README.Debian
    define('ABSPATH', '/usr/share/wordpress/');

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

  4. MichaelH
    Posted 7 years ago #

    Sorry--here's the full link:

    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
    Posted 7 years ago #

    Looks like a file called


    holds the database information.

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