“Error Establishing a Database Connection” in WordPress After Changing WordPress Address and Site Address

Error Establishing a Database Connection in WordPress After Changing WordPress Address and Site Address

“Error Establishing a Database Connection” in WordPress After Changing WordPress Address and Site Address

            I installed WordPress in a VPS. In the General settings of the Dashboard, the WordPress Address and Site Address text box had the IP address of the server instead of the domain name. So I manually changed the IP address to the domain name after which I got an error “Error Establishing a Database Connection”. Then the WordPress blog or the admin page was not opening.  This problem may be due to insufficient memory(RAM) or there may be problem with wp_options table in the WordPress database.  First reboot the server which may solve the problem .If the problem still persist follow the below steps to check with the wp_options table. Note that the below steps works only if you have configured your DNS. Follow the below either using GUI or Command Line Interface.

Using GUI (phymyadmin):

          If you have access to the database with GUI like phpmyadmin you can login and access the wp_options table in wordpress database directly. Note that “wp_” is the prefix of the table name which may differ based on your settings.

set option_value=”domainname” for the entry option_name=”home”

Example: domain name=”http://www.teknosrc.com”

set option_value=”domainname” for the entry option_name=”siteurl”

Example: domain name=”http://www.teknosrc.com”

Note that the domain should have the prefix http://.


Using MYSQL Command Line in Ubuntu Linux

1. Open the MYSQL command line interface using the command “mysql” in terminal.

2. Use the command “show databases;” to get the lists of databases.

3. Now use the command “use database_name;” to use the required database. In our case         the database name will be “wordpress

4. Run the below command.

select option_name,option_value from wp_options where option_name=”siteurl” or option_name=”home”;

Error Establishing a Database Connection in WordPress

        In the above image you will find the IP address of the server where you have hosted the WordPress blog in the white shaded block. Now you need to change the URL parameter to the domain name.

5. Run the below commands to update the entries

UPDATE wp_options SET option_value=”domain_name” WHERE option_name=”siteurl”;

UPDATE wp_options SET option_value=”domain_name” WHERE option_name=”home”;

Example:

UPDATE wp_options SET option_value=”http://teknosrc.com” WHERE option_name=”home”;

6. Now you can verify the the table by running the select command again.

select option_name,option_value from wp_options where option_name=”siteurl” or option_name=”home”;

Error Establishing a Database Connection

“Error Establishing a Database Connection” in WordPress

     Now you will have your domain name entry in the table and the blog should open in proper way.

Related Links:

  1. 7 Must Have Plugins/Widgets For WordPress Blog/Website
  2. Search Bar HTML Widget for WordPress Without Using Plugins
  3. Import Blogger to WordPress – Formatting Problem/Issues
  4. How to improve WordPress performance with browser caching (through .htaccess)
  5. “Error Establishing a Database Connection” in WordPress After Changing WordPress Address and Site Address
  6. MYSQL on Linux(Ubuntu) keeps crashing – Solution is to create Swap Space
  7. Blogging Tips & Guidelines – SEO, Backlinks and Design
Read More...

[ YOU MAY ALSO LIKE ]

Leave a Reply