Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

Error Establishing a Database Connection in WordPress

Error Establishing a Database connection

While you are working with WordPress, you may have seen this error establishing a database connection at least once.It could be a MySQL database connection issue .It could be wrong login credentials and need to repair your database and MYSQL server is unresponsive.

How to fix Error Establishing a Database Connection in WordPress ?,based on any one of the following cause,you need to solve this problem.

Repair wp-admin Database

Reset MYSQL password

MYSQL server unresponsive

MYSQL Database User Has Limited Privileges

Repair Database for WP-admin

The only wp-congfig.php file is located in your c panel's file manager section.Before that you need to allow to repair your database ,it can be easily done by adding the following code to your wp-config.php file.

define('WP_ALLOW_REPAIR', true);

After adding the code,just enter this url path in the browser to repair database.

http://www.yourwebsitename.com/wp-admin/maint/repair.php

error-establishing-a-database-connection

Here you need not to be logged in to repair database.WordPress automatically fix this error establishing a database connection.If problem fixed,then remove the above code from your wp-config.php file.

If problem not solved jump to next possible issue of mysql reset password.

Wrong MYSQL database Login Credentials

In most of the cases you can see the error establishing a database connection in WordPress due to wrong mysql database login details.You should reset mysql password in order to get back your website. Open your wp-config.php by using cpanel login credentials.Under file manager you can see a file name called wp-config.php,which stores the your wordpress database the details of database name, database user, database password and database host.Now reset your password in wp-config.php file.

define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost');

This problem often due to changing the root password or database user password.You need to change the same in your wp-config.php file.

Sometimes your BD_HOST valud always may not be localhost.It's totally depends on your webhosting company.You can see this localhost value in Hostgator and Bluehost.

Make sure all values in wp-ocnfig.php file are correct.If database repaired this problem solved.If not follow to next issue might be MYSQL server side.

MYSQL Server is Unresponsive

Error establishing a database connection also happens due to high traffic to your website with shared hosting plan.Will you MYSQL server responsive ?,in most of the cases if your website gets high traffic,then your mysql server becomes unresponsive due to shared web hosting.

To fix this issue,contact your hosting company or do it your self with following instructions.

1.Log on to cpanel with credentials
2.Open phpMyAdmin and connect to database
3.Create a new file and name it testconnection.php. Add the following php code and replace the username and password.
4.If problem not solved contatc your web host support.

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

MYSQL Database User Has Limited Privileges

In rare cases,MySQL database user privileges can become corrupted or limited.Then you need to delete current user and connect your database with new user.To fix this issue,open your wp-config.php,than replace old database username with new username.

Related Posts

  • How to Avoid CSS @Import in any WordPress Child Theme
  • How to No follow External Links in WordPress
  • Remove WordPress Emoji Script and Style
  • How to Add Related Posts with Thumbnails in WordPress
  • How to Create a Mobile Friendly Responsive Menu in WordPress
  • Display WordPress Popular Posts by Comments Count
  • Recommended WordPress Ping List 2017
  • How to Disable Emojicons in WordPress 4.2
  • How to Combine External CSS Files in WordPress
  • Show one category Posts on Home Page in WordPress 2015 theme

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial