{"id":71,"date":"2011-06-14T18:13:26","date_gmt":"2011-06-14T18:13:26","guid":{"rendered":"http:\/\/www.websitedesignwebsitedevelopment.com\/?p=71"},"modified":"2014-03-19T09:14:26","modified_gmt":"2014-03-19T09:14:26","slug":"error-establishing-a-database-connection","status":"publish","type":"post","link":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/","title":{"rendered":"Error establishing a database connection"},"content":{"rendered":"<h2>Error establishing a database connection<br \/>\n  <\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2011\/06\/mysql.png\" width=\"350\" height=\"181\" align=\"right\" \/><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2011\/06\/wordpress.png\" width=\"499\" height=\"113\" align=\"right\" \/><\/p>\n<p style=\"clear:both\">WordPress is a sophisticated framework and a lot of help  available online. Please have a look in your wp-config.php and also check the  followings to make sure that configuration is correct.<\/p>\n<p>  1- <br \/>\n  \/** MySQL hostname *\/<br \/>\ndefine(&#8216;DB_HOST&#8217;, &#8216;localhost&#8217;);<\/p>\n<p>:: Normally this constant remain as it is as localhost, make  sure that your phpmyadmin referring to the same host.<\/p>\n<p>2- <br \/>\n  \/** MySQL database username *\/<br \/>\n  define(&#8216;DB_USER&#8217;, &#8216;yourmysqluser&#8217;);<\/p>\n<p>:: It has prefix of your domain name sometimes and mostly it has first eight letters of your domain with underscore. You can check it from you cpanel.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2011\/06\/mysql_databases.png\" width=\"405\" height=\"293\" \/><\/p>\n<p>By clicking on MySql Databases, you can have a look on existing databases and users. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2011\/06\/mysql_databases1.png\" width=\"532\" height=\"390\" \/><\/p>\n<p>3-<\/p>\n<p>\/** MySQL database password *\/<br \/>\n  define(&#8216;DB_PASSWORD&#8217;, &#8216;yourmysqlpassword&#8217;);<\/p>\n<p>  :: You can not obviously reset your password, just remove exisitng user and create a new one. And don&#8217;t forget to add that user to the required database, it means that you are giving that user specific or all privillages for DQL, DML etc. <\/p>\n<p>4-<br \/>\nOnce you have created or checked the username, password and database etc. Now access phpmyadmin from your cpanel.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2011\/06\/phpmyadmin.png\" width=\"660\" height=\"284\" \/><\/p>\n<p>And verify that do you putting DB_HOST &amp; DB_NAME correctly?<br \/>\nIf everything is correct but still wordpress is displaying the same error, go to your wp-config.php and check do the followings:<\/p>\n<p>1- Try to connect to your database by simple php mysql_connect() function.<\/p>\n<p>2- Try to echo your constants which are DB_HOST, DB_NAME etc, are they displaying the correct information?<\/p>\n<p>  3- Hopefully you will get your problem resolved, if not yet then try a different copy  of wordpress to install again. Or finally you can have a look on your hosting as well, sometimes we get PHP running fine but hostings do have separate databases servers. Hosting support will guide you regarding this. Error establishing a database connection is obviously a simple but can make trouble when it prevents our website to be displayed just after uploading it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error establishing a database connection WordPress is a sophisticated framework and a lot of help available online. Please have a look in your wp-config.php and also check the followings to make sure that configuration is correct. 1- \/** MySQL hostname *\/ define(&#8216;DB_HOST&#8217;, &#8216;localhost&#8217;); :: Normally this constant remain as it is as localhost, make sure [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":76,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>error establishing a database connection<\/title>\n<meta name=\"description\" content=\"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"error establishing a database connection\" \/>\n<meta property=\"og:description\" content=\"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\" \/>\n<meta property=\"og:site_name\" content=\"AndroidBubble Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-14T18:13:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-03-19T09:14:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png\" \/>\n\t<meta property=\"og:image:width\" content=\"499\" \/>\n\t<meta property=\"og:image:height\" content=\"113\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Fahad\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fahad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\"},\"author\":{\"name\":\"Fahad\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"headline\":\"Error establishing a database connection\",\"datePublished\":\"2011-06-14T18:13:26+00:00\",\"dateModified\":\"2014-03-19T09:14:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\"},\"wordCount\":333,\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png\",\"articleSection\":[\"MySql\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\",\"url\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\",\"name\":\"error establishing a database connection\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png\",\"datePublished\":\"2011-06-14T18:13:26+00:00\",\"dateModified\":\"2014-03-19T09:14:26+00:00\",\"author\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"description\":\"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error\",\"breadcrumb\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage\",\"url\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png\",\"contentUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png\",\"width\":\"499\",\"height\":\"113\",\"caption\":\"wordpress\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/androidbubble.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Website Development\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Frameworks\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Wordpress\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"MySql\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/mysql\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Error establishing a database connection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\",\"url\":\"https:\/\/androidbubble.com\/blog\/\",\"name\":\"AndroidBubble Blog\",\"description\":\"Articles &amp; Posts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/androidbubble.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\",\"name\":\"Fahad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"caption\":\"Fahad\"},\"sameAs\":[\"http:\/\/www.androidbubbles.com\/\",\"https:\/\/x.com\/phpFlex\"],\"url\":\"https:\/\/androidbubble.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"error establishing a database connection","description":"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/","og_locale":"en_US","og_type":"article","og_title":"error establishing a database connection","og_description":"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error","og_url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/","og_site_name":"AndroidBubble Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453","article_published_time":"2011-06-14T18:13:26+00:00","article_modified_time":"2014-03-19T09:14:26+00:00","og_image":[{"width":499,"height":113,"url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","type":"image\/png"}],"author":"Fahad","twitter_misc":{"Written by":"Fahad","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#article","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/"},"author":{"name":"Fahad","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"headline":"Error establishing a database connection","datePublished":"2011-06-14T18:13:26+00:00","dateModified":"2014-03-19T09:14:26+00:00","mainEntityOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/"},"wordCount":333,"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","articleSection":["MySql"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/","url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/","name":"error establishing a database connection","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage"},"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","datePublished":"2011-06-14T18:13:26+00:00","dateModified":"2014-03-19T09:14:26+00:00","author":{"@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"description":"error establishing a database connection is an article related to wordpress users who first time uploading a website and gets this error","breadcrumb":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#primaryimage","url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","contentUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","width":"499","height":"113","caption":"wordpress"},{"@type":"BreadcrumbList","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/mysql\/error-establishing-a-database-connection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androidbubble.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Website Development","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/"},{"@type":"ListItem","position":3,"name":"PHP Frameworks","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/"},{"@type":"ListItem","position":4,"name":"Wordpress","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/"},{"@type":"ListItem","position":5,"name":"MySql","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/mysql\/"},{"@type":"ListItem","position":6,"name":"Error establishing a database connection"}]},{"@type":"WebSite","@id":"https:\/\/androidbubble.com\/blog\/#website","url":"https:\/\/androidbubble.com\/blog\/","name":"AndroidBubble Blog","description":"Articles &amp; Posts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androidbubble.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7","name":"Fahad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","caption":"Fahad"},"sameAs":["http:\/\/www.androidbubbles.com\/","https:\/\/x.com\/phpFlex"],"url":"https:\/\/androidbubble.com\/blog\/author\/admin\/"}]}},"views":1188,"jetpack_featured_media_url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2011\/06\/wordpress.png","_links":{"self":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":5,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":1720,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions\/1720"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media\/76"}],"wp:attachment":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}