Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

Tutorial Reasons For Error Establishing Data Connection When Built Your Website Using Wordpress

Discussion in 'PHP Programming' started by Prasoon Arora, Feb 5, 2016.

  1. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    Error establishing database connection is of the common occurring error that any one can face, while updating the website or accessing database through phpmyadmin.

    The reasons due to which this error are as mentioned below :

    1. If you are using your credentials incorrectly, in terms of username or password.
    You need to make sure that the database name (DB_NAME), user name (DB_USER), and password (DB_PASSWORD) are all used correctly.

    2. Your software that you are using may be outdated or is not compatible.
    You need to update Wordpress to the latest version as this error occurs when you are using outdated version or Wordpress or mysql database.
     
  2. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    3. Missing of wp-config.php file from your database
    4. Changing in title, url, blog info
    5. Database table got corrupted
     
  3. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    Changing in title, url or blog info would cause your website in not getting displayed.

    The index.php coding for any blog to work properly :

    <?php define

    ('WP_USE_THEMES', true);
    define('WP_IN_ROOTDIR', true);
    require('.//blog/wp-blog-header.php');

    ?>

    Here in index.php, if url, or title or any info is being changed, the coding in third line would be interrupted and you would not be able to see your blog.

    Example : If my name of Blog is being changed from "blog" to "newblog", php would not be able to execute the path of your blog located in your file manager.

    Solution :
    Updating the name as in require('.//blog/wp-blog-header.php'); to ('.//newblog/wp-blog-header.php'); will gives your blog back to the server.
     
  4. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    Just change the title, url and tagline and repeat the task after correction and save. Open your WordPress website after correction in new tab, What will you see?
     
  5. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    To be very frank I have never face but would soon will be trying the same. What researched, I have below mentioned results :

    Changing the tagline or url, redirects your web page . I really thank you to help me in adding more information to my database. What I come to know would like to share as mentioned below :

    re: changing a site title or tagline
    The Site title (blog name) and/or the optional Tagline can be changed on the top of the page at any time. > Settings > General ... "save changes".
    That is exactly where search engine spiders look for the site title and removing it from there can cause issues with getting your content indexed. Accessing the database can easily be made with the help of phpmyadmin and after you repaired the database, mysql forms the data again in sequential manner.

    Note that the site title (blog name) and blog address URL do not have to be the same but it's better for SEO (search engine optimization) if they are the same.

    All that changes when your domain mapping is the URL and nothing else. The content stays exactly where it is. What domain mapping does its create a seamless transfer between the underlying .wordpress.com blog URLs to the domain URLs no matter where they are on the internet. The change in the name the title, url and tagline do not cause much effecting to the database, untill or unless the change is being made by missing files as mentioned in your 3 point Missing of wp-config.php file from your database.

    I would request you to please provide the screenshot so that we all can be aware of the fact, and I can improve our skills more.

    To see the details you may also refer to en.forums.wordpress.com/topic/change-blog-url-name-2.
     
  6. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
  7. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    It was really a great feedback given in the link and when read all the matter. Below is what I found by following your link :

    1. Changes made under Settings/General Settings as 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.

    Result : Reloaded the page and I get the response "Error establishing a database connection."

    2. Tried to login to adnep.org/wp-login.php
    Result : "Error establishing a database connection."

    3. Tried to go to adnep.org/wp-admin/page.php
    Result : Database may need to be repaired

    At last when read all, it was mentioned :

    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.

    Really appreciated your research, to helping in adding more knowledge to what I have experienced in my 10 years of experience with Wordpress.

    Deleting the title, url, blog info, have may have sequentially affected the database and when the data was placed back it could not holds its own position which caused the error.
     
  8. bharath

    Staff Member Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    772
    Ratings:
    +54 / -0
    Most of the times I get the errors atleast three to four times a month and the option was the 1st one that server is down.
    If I switched to another host or the files changed then the option would be second one for causing Database errors.

    For the reason 3 you should have tested by repairing the database and further investigations would be found.
     
  9. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    @Prasoon Arora@Prasoon Arora :Life is all about learning. I'm glad you find that given link useful and i find your piece pf content very useful for me. In fact, each of your post is full of new information especially because you happen to write on technical specification every webmasters curious to know about.
    I hope there will be more to see from you.
    Your contents are as sweet as Palasia sweets.
     
     
  10. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    @Manish Mishra@Manish Mishra : It seems that exploring and experimenting things are going to work more, as if when one or more than one experiences combines it forms the whole book. I am really glad to have your words and knowing more for Error Establishing Database

    @bharath@bharath : Most of the time when I repaired the database, the results is what I want. My other efforts made are deactivating plugins, activating Wordpress manually and then repairing the database again.
     
    #10 Prasoon Arora, Feb 5, 2016 at 10:12 PM
    Last edited: Feb 5, 2016
  11. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    I am little doubted as the @bharath@bharath is saying he finds this error message, "Error establishing a database connection" while he moved to another website. Is moving from one host to another give such error message. I don't think so.
    I am sure he might be doing something wrong to receive this message, Your thoughts please?

    Ps: @bharath@bharath Maybe this tutorial can help you. I written on the base of my own experience and i tell you this, It won't let you see that error message if you follow the same.: Tutorial - How To Migrate Your Wordpress Website From One Host To Another
    I hope it helps!
     
  12. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    @Manish Mishra@Manish Mishra @bharath@bharath :

    Manish, I totally agree with what bharath mentioned : switching to another host or the files changed then the option would be second one for causing Database errors. The reasons being , different host may provide their own user account, as you would have experienced in Filezilla, user account when made from Password Manager for accessing File Manager.

    How It Works ?

    When any user account, contact the server with wrong host credentials, or lets say the credentials used with GoDaddy, cannot contact with credentials used for Hostgator.

    Filezilla, is commom FTP client, and can be used by as many of user you provide, When the credentials collabrate with different host, separately, the error occurs.

    Example :

    1.I have two websites : xyz.com and abc.com. when I am trying to update the files for abc.com to xyz.com it will not accept and will return the same error as mentioned by bharath
    2. I have experienced, while sharing my web files between two host, the reason why the error occurs :
    • their different name servers,
    • some have dynamic IP some may not,
    • some may allow you to access .htaccess or php.ini files some may not as Yahoo/ Aabaco
    • the credentials for different host are different, even if used for same FTP client,as experienced with Filezilla, Cyberduck,SmartFTP, iWeb and Fetch
     
  13. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    @Prasoon Arora@Prasoon Arora
    1. I am keeping my Files and database and current server.
    2. I have moved, assigned domain name to new server.
    3. Moved Database, all Files themes as it to new server.
    4. Just changed the NS (also best practice to avoid downtime)

    Do you happen to see any error message?
     
  14. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    @Manish Mishra@Manish Mishra
    I agree to what you said changing the name servers to the host you are going to transfer your files.

    How it helps ?

    Changing the name servers, provide the access to your host company to manage the settings for your services as mentioned below :
    • A records/ C name : for updating and managing IP addresses for your website.
    • MX records, to make sure your emails work properly, as if not you would be facing issues in sending/ receiving messages.
    • and the rest subdomains :
      ftp.domainname.com which is responsible for the sharing of your files.
     
  15. bharath

    Staff Member Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    772
    Ratings:
    +54 / -0
    @Manish Mishra@Manish Mishra
    It happens to everyone as what the OP said and for me it happens normally sometimes.
    @Prasoon Arora@Prasoon Arora
    You should have some backups, try importing each table and find the problem where it is happening. Deactivating or Activating plugins, themes cause problems with most CMS.
    Also check the error log files in hosting to find further investigations, but the easiest thing is install a fresh copy, then import the tables one by one if anything goes wrong in database.
     
  16. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    It does not happen to me at all. At least when i am moving my sites. I already gave you the tutorial. It will help you too buddy. Next time follow that.
     
  17. Prasoon Arora

    Yellow Belt

    Joined:
    Feb 1, 2016
    Messages:
    472
    Ratings:
    +24 / -0
    @bharath@bharath
    We usually make backups of our website, as we can not compromise with our own creativity and hard work to build any website before transferring to new host.

    As you said, I prefer to log files, and it really helps in detecting the error as it gives you the exact reason of error. But sometimes these secured plugins like Jetpack, and all also cause errors as some of the host providers do not allow you to access secure files under their terms and policies as experienced under many Web Hosting services. Changing themes or plugins, reactivating them manually also works sometimes.
    Please experience, sharing and accessing .htaccess files and php.ini files, considered in regards to password protect your page
     
  18. bharath

    Staff Member Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    772
    Ratings:
    +54 / -0
    It never occurred either with me, while shifting files to another host. It occurred long back where the service provider offered their own data base names, currently I am using hostdime and their services are poor as the site goes error database connection, later it returns because they fix it in short time period.

    The Op said actual things in his guide to check the issue if they experience in Error Establishing Data connection. There may be more factors, but these two are very essential to check for anyone.
     
  19. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    I really don't understand the situation. Maybe, because i am not aware of these technical aspects but still possible dealt and gone through migration process without seen that error window. It really annoys when there is solution and you persuade yourself to get an error message like it will be an award or something.

    Besides, we need to talk more about the positive aspects of a thing even if it isn't curable (here it is curable easily of course)
    I hope this thread will be really helpful for those who are looking for solutions or those who are stoned to not find a solution.
     
  20. bharath

    Staff Member Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    772
    Ratings:
    +54 / -0
    @Prasoon Arora@Prasoon Arora
    I am not a big fan of Wordpress thought what I know that shared with you as my plugins are somewhere 5 to 8 and that all were small, supported by every hosting company.

    As you said Jetpack, secured plugins, then you need a good host might be a VPS suitable for you.
    I think @Manish Mishra@Manish Mishra may have an answer for you or someone will help in this regard. It's good to see so many problems that cause in database connection.
     

Share This Page