• Home
  • About
    • About Us
    • Our Team
    • Case Studies
  • Services
    • E-Commerce Solutions
    • Mobile Application Development
    • Web Development / Enhancement
    • WeChat Official Account for Business
      • WeChat Subscription Account
      • WeChat Service Account
      • WeChat Mini Program
      • Our Clients
    • Internet Marketing & Advertising
    • Web Hosting & Domain
  • Coding Academy
  • Blog
  • Contact Us

WordPress Database Connection Error even Database Setting is Correct

April 5, 2020

  • 0 Comments
  • Bravo Net
  • Tips & Tutorial, WordPress

You will find it weird when you get an error establishing database connection while trying to set up your WordPress and you’ve made sure that your database name, username, and password is exactly the same as your wp-config.php file. Well, assume that you have your database setup correctly, your username and password is correct, you have also linked up your database & username together and the privilege to access the WordPress database is correct. Once refreshing your WordPress page you will get an error “Error establishing a database connection“.

How to debug your WordPress database connection

One way to debug your WordPress database connect is to go to your wp-config.php look for

define( ‘WP_DEBUG’, false );

and change it into “true”.

Usually you will get the follow error,

Warning: mysqli_real_connect(): (28000/1045): Access denied for user ‘username’@’localhost’ (using password: YES) in /home/username/public_html/wp-includes/wp-db.php on line 1531

I totally understand your frustration right now. The devil lies under your password’s character. When you open up your wp-config.php,  look for

/** MySQL database password */
define( ‘DB_PASSWORD’, ‘your-password-here’ );

Solution for WordPress database connection error even database setting is correct

Most of us are using complicated passwords with the combination of special characters such as underscore, line, slash, backslash, single quote or apostrophe, double quote, etc. You can generate your complicated password from this website – https://passwordsgenerator.net/.

With all these combination characters of password, you will need to avoid single quote or apostrophe – ( ‘ ). Apostrophe will end up messing up your DB_PASSWORD defined in the config setting. As you can see,

This password will return syntax error and 500 to your website.

This password will return Database Connect Error.

This password will work fine.

 

Post Views: 813

Post navigation

← Previous Post Previous post:
Next Post → Next post:

About Author: Bravo Net

All Comments


    Write a Comment

    Cancel

    ABOUT US

    Bravo Net Solution is a digital agency dedicated to building a better internet by providing innovative solutions to clients with the vision to have their businesses connected to the digital world.

    FIND US

    Address
    Unit 1009, Lobby 3, 10th Floor, Block A,
    Damansara Intan, Jalan SS20/27,
    47400 Petaling Jaya, Selangor Darul Ehsan
    Malaysia

    Hours
    Monday—Friday: 10:00AM–6:00PM

    Contact
    Tel: +6011 2020 9588
    Email: [email protected]

    Quick link

    E-Commence Solutions

    Mobile Application Development

    Web Development / Enchancement

    WeChat Development Services

    Internet Marketing & Advertising

    Web hosting & domain

     

     

     

     

    ©Copyright 2017 Bravo Net Solution, a wholly owned subsidiary of Sapiens Technologies Sdn Bhd. All Rights Reserved.

    FacebookLinkedin
    We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok