WordPress.org

Ready to get started?Download WordPress

Forums

Error establishing a database connection (20 posts)

  1. tranquilmoods
    Member
    Posted 4 years ago #

    Hi.

    I know there's been quite a lot of posts about this one. I've tried all the recommendations that were written on those posts but to no avail.

    I do not know much about codes so please bear with me if I don't get your answer the first time.

    This is what happened:

    1) I made changes under Settings/General Settings.
    I deleted the Blog Title, Tagline and Blog Address URL then I clicked Save Changes. I tried to open the it thru a new tab window but nothing happened. So I placed back the initial values written in Blog Title, Tagline and Blog Address URL and clicked Save Changes again.

    2) Then I reloaded the page and I get the response "Error establishing a database connection."

    3) I tried to login to http://www.adnep.org/wp-login.php but I also get the message "Error establishing a database connection."

    4) I tried to go to http://www.adnep.org/wp-admin/page.php and then I get this message "One or more database tables are unavailable. The database may need to be repaired" which I did wherein I added define('WP_ALLOW_REPAIR', true); to the wp-config.php file.

    After I reloaded it, this message appeared:

    One or more database tables is unavailable. To allow WordPress to attempt to repair these tables, press the "Repair Database" button. Repairing can take awhile, so please be patient.

    Repair Database
    WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing.

    Repair and Optimize Database

    I clicked on Repair and Optimize Database the following appeared:
    The wp_users table is okay.
    The wp_users table is already optimized.

    The wp_usermeta table is okay.
    The wp_usermeta table is already optimized.

    The wp_posts table is okay.
    The wp_posts table is already optimized.

    The wp_comments table is okay.
    The wp_comments table is already optimized.

    The wp_links table is okay.
    The wp_links table is already optimized.

    The wp_options table is okay.
    The wp_options table is already optimized.

    The wp_postmeta table is okay.
    The wp_postmeta table is already optimized.

    The wp_terms table is okay.
    The wp_terms table is already optimized.

    The wp_term_taxonomy table is okay.
    The wp_term_taxonomy table is already optimized.

    The wp_term_relationships table is okay.
    The wp_term_relationships table is already optimized.

    The wp_commentmeta table is okay.
    The wp_commentmeta table is already optimized.

    Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.
    define('WP_ALLOW_REPAIR', true);

    5) I took off define('WP_ALLOW_REPAIR', true); from the wp-config.php file then reload and Error establishing a database connection would still appear.

    6) I've got in touch with my host and they said that they have tested the database connectivity without error. I was told by my host to disable any plugins to see if that is the cause of the error.

    7) I've already checked the connection strings and so far, it's the same values as written in my wp-config.php file.

    Questions:

    1) How do I disable any plugins?

    2) Is there a System Restore with WordPress just like in Windows so I can restore it at an earlier time?

    3) Is there hope?

    Thank you for your time.

  2. MichaelH
    Member
    Posted 4 years ago #

    3) Is there hope?

    I believe so ;)

    That message, "Error establishing a database connection", usually means one of two things:
    1. Database server is down (not operating)
    2. You have wrong information in your wp-config.php--either the DB_HOST, DB_USER, DB_PASSWORD, or DB_NAME is incorrect.

  3. tranquilmoods
    Member
    Posted 4 years ago #

    Hi Michael.

    I've checked it out a couple of times. I even followed a video tutorial from one of the posts here in wordpress.

  4. MichaelH
    Member
    Posted 4 years ago #

    Then please consider asking your host if the server is working, and if so, do they concur with your DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME, settings.

  5. tranquilmoods
    Member
    Posted 4 years ago #

    Ok. I will get in touch with the hosting again.

    Questions:

    Does this message One or more database tables is unavailable have a connection with the "Error establishing a database connection or is it a completely different problem?

    If I will be able to get the correct string for wp-config.php, I will no longer have to worry about repairing a database?

    And lastly, is it safe to confirm with the hosting if I have the correct strings (ie. give them the connection strings that I am using)?

    Thank you.

  6. MichaelH
    Member
    Posted 4 years ago #

    Does this message One or more database tables is unavailable have a connection with the "Error establishing a database connection or is it a completely different problem?

    I'd say completely different.

    And lastly, is it safe to confirm with the hosting if I have the correct strings (ie. give them the connection strings that I am using)?
    You should be okay confirming that with them.

  7. tranquilmoods
    Member
    Posted 4 years ago #

    Hi.

    All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…

    Run the install

    What happens if I click Run the install?

    Will it delete my database and install a new one?

  8. MichaelH
    Member
    Posted 4 years ago #

    No, it creates tables in the database and poplulates those tables with initial data.

    If you have an existing database that has posts in it, then you either have the wrong database information in wp-config.php or the wrong $table_prefix.

  9. rumad
    Member
    Posted 4 years ago #

    Im having exactly the same problem as tranquilmoods. My blog has been up and running for weeks without any problems. Today I made amendments in the Settings/General Settings and since this it has broken! The admin system says "One or more database tables are unavailable" and the front end says "Error establishing a database connection". Therefore these messages must be due to the same error. This can't have anything to do with the settings in the wp-config.php file as these have not been changed. The database is not down either.

    I have repaired the database as stated above but stil no luck. I dont know what else to do. How was this problem resolved for you? its not very clear inthe above posts. I get lost after the post from tranquilmoods stating "Ok. I will get in touch with the hosting again."

    Any help will be much appreciated.

  10. MsSalahuddin
    Member
    Posted 4 years ago #

    Hello,

    I upgraded to WordPress 2.9.2. And I received this error during the upgrade: Upgrading...
    Initializing Parameters - Done.
    Generating MySQL Backup - Done.
    Generating Files Backup - Done.
    Warning: file_get_contents(http://completemakeupguide.com/wp-admin/upgrade.php?step=1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /tmp/cpanel_phpengine.1268162039.22031Dk88f5xD3V on line 2090

    I tried to restore the database with the instructions that were given to me: Please save following information. You will need it in order to restore if something went wrong . . .
    Every time I try to Import the file backup.sql into the database I get the following error:
    There is a chance that you may have found a bug in the SQL parser. Please examine your query closely, and check that the quotes are correct and not mis-matched. Other possible failure causes may be that you are uploading a file with binary outside of a quoted text area. You can also try your query on the MySQL command line interface. The MySQL server error output below, if there is any, may also help you in diagnosing the problem. If you still have problems or if the parser fails where the command line interface succeeds, please reduce your SQL query input to the single query that causes problems, and submit a bug report with the data chunk in the CUT section below:
    ----BEGIN CUT----
    eNrtlFtr2zAUgP2sX3EeyrqG+CLbshf3YctCyEbTJIu7FvZSlERLRH1RLZlt/36yR9gFwgZjhcE5
    L7LPOZKMv8M3Xa+X6wwmFCYhzKeLDNgIkgDSMEpIfmNLDiH5rc2fvd1loB8LxRstGq+QG08dFNCI
    0hTCIBi5lLqU2UTGgiwKP0AhyhGckesv+bu5PdejXhSQ9/kalvkQxrPp4mYIt1N7xZ2sYDadXC2B
    eiOyuh5nEHmhF5PVm1XXMVzm3X6bgbms2s9kPl7MMhCV25qP7gvSn3+oS+GXmpdCVNxX7aaQ2/uD
    KQt/W5eqEEaU/EG0at/KnfBszv+kXL4rZeU7fxqBjZSxbqX24cf1GA6lURQkMQvTxAnCmCXMAeY8
    QbTa8AbAOf6DU32/q/+n8Rf8a2VkXWl3LyrR8KKb69P8kzg+wT9kIUt6/imz4GPLPwrikDoQIP9/
    Hs8Kc/nSkiP+YEBgALNvMEELY2S119Czlto0vKMNilei8Gxn1/xK8e0D3wu4q5vdqhFa91ndbo6F
    8U+7bdUn3U3fN/zSAa/r2nQvqmttxGMrG3FfV1vx/Nzz+2/p5uz84hLFheJCcaG4UFwoLhQXigvF
    heLCwUVxIX8UF4oLBxfFhfxRXCguFBeKC8X1xOL6Cm5TxtU=
    ----END CUT----
    ----BEGIN RAW----

    Please help . . .

  11. macnewbold
    Member
    Posted 4 years ago #

    I don't know that my problem was exactly the same as everyone else is having, but yesterday I was having some trouble after migrating a database. We have several servers where we develop and test our WordPress work, and often the simplest way to move all the data over is by copying the database and files, and adjusting the site URL for the new server. Often though, that leaves the old URL sprinkled throughout the database, like on the post GUIDs and in some of the other fields here and there, like post content when it used an absolute link.

    The way I was fixing that yesterday was by doing a search and replace of the old URL with the new one in a mysqldump of the database, then loading the modified dump. The problem I found was that some of the data in the database is JSON encoded, where it stores a string by giving the type ('s') the length (i.e. 35) and then the content of the string (i.e. "http://localhost/myblogurl"). But when I replaced the old URL with the new URL, it changed the length of the string, and originally I hadn't been changing the length number.

    When I had invalid JSON in my database, it gave me exactly the results everyone is describing: "error establishing a database connection" even though the credentials are correct, the admin saying the tables might need to be repaired, and the repair and optimize process saying everything is fine, but the problem still occurring. I found that when I fixed the string lengths then everything got happy again.

  12. MsSalahuddin
    Member
    Posted 4 years ago #

    I'm not as savvy with SQL and JSON in my database . . . could you please be more detailed in your fix? I would be most grateful as my database has been down for almost 48 hours.

  13. ralphkooi
    Member
    Posted 4 years ago #

    Hi
    I've got the exact same problem.
    Tried to do something and then got the same database errors.

    I've done the repair script and said all tables ok so I removed the extra line and restarted. No dice, it went back to the initial page where I needed to add the same line of code to repair the db.

    Tried to run the installation again, as mentioned in this post, but that only gets me back to the error page, and the page which tells me to put the repair code in the php file.

    Can anyone help?

  14. sokol99
    Member
    Posted 4 years ago #

    Hi all, I just hit the same error. I took some bad advice on the general setting page and just erased the url references because I was told it would be best to leave them blank. This was the only change I made.

    Upon trying to save I was immediately greeted with an error - that is, the initial error came before doing the table up 'update' bit every mentioned above....

    Seems to me the URL change was saved somewhere upon hitting save and that broke the code at that point. It would take me a little while to figure out just where that happened but I don't have much else I can do at this point...

  15. sidarcy
    Member
    Posted 4 years ago #

    Hi Guys

    I am new to WordPress but have made my own CMS's before so have ran into similar problems.

    At the end of the day, everything is in the SQL Database.

    I ran into this problem after i removed the URL from the settings, I dunno why this happened!

    I fixed the problem by logging into PHP My Admin

    In your Database go to the table wp_options

    When in here click browse, this lists all the information

    You will notice the site URL value is blank.

    Click the edit button(looks like a pencil) and re input your URL into the Value text area and click save.

    Alternatively in the SQL Console add the following line

    UPDATE YOUR DATABASE NAME.wp_options SET option_value = 'http://YOURURL' WHERE wp_options.option_id =2 LIMIT 1 ;

    ps: careful when copying the above line as the quotes may need to be re-entered

  16. sokol99
    Member
    Posted 4 years ago #

    Thanks sidarcy; that worked like a charm! I'm back in business. :)

  17. kkarpieszuk
    Member
    Posted 4 years ago #

    i had exactly thesame problem as thread's author ('error establishing database connection' at site and info about missing table in /wp-admin, while mysql server was running), i solved this problem but reason was diffrent than this which was described by sidarcy. i will describe how i did it :)

    - i went to phpmyadmin, everything looked good
    - i went to wp_options table and phpmyadmin showed me that this table is broken and should be repaired
    - so i went again to list of all table i checked wp_options table and from select menu at bootm i choosed 'repair'

    now everything works :)

    tip: if your wp_options table is fine, check other tables in thesame way as described above

  18. alex.galpin
    Member
    Posted 3 years ago #

    Hi, I have exactly the same problem - when I tried to remove the blog title address - I refreshed twice and got the database connection error. Is it a problem on the hosting side? Or is it a bug on wordpress?

  19. a1588
    Member
    Posted 3 years ago #

    Thank you everyone discuess. I have exactly the same problem.
    I find two line option_value of wp_options table is empty.
    I change it to my site url.
    "2 0 siteurl " ---> "2 0 site url http://www.a1588.info"
    now everything works :)

  20. Tanner Waid
    Member
    Posted 3 years ago #

    One or more database tables are unavailable. The database may need to be repaired.

    I got this message when I tried to upload WordPress to my new site. I have worked with WordPress quite often but I have never seen this before, what does it mean, and better yet how do I fix it. I tried to repair the database but it wont go through with it completely. Anything would help!!

Topic Closed

This topic has been closed to new replies.

About this Topic