• Resolved aegirr

    (@aegirr)


    I am trying to install WordPress on my local computer but I keep getting this classic message “Error establishing a database connection”.

    I have tryed the following:

    1. I make sure the MySQL database and the web server is running.
    2. I make sure username, name of the database and password is correct.
    3. I have checked wp-config.php many times for errors/typo. I have tryed this

    define(‘DB_HOST’, ‘127.0.0.1:3306’);

    and this

    define(‘DB_HOST’, ‘127.0.0.1:8889’);

    instead of this

    define(‘DB_HOST’, ‘localhost’);

    but I still get the error-message

    Any ideas?

    I have actually installed WordPress on another PC many times without any errors, so why should I get this now?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    I would recommend you to read this five minutes post.

    Hope you’ll find the solution ??

    What local server are you using and which operating system?

    e.g. MAMP and Mac OS? Windows and XAMPP?

    Going by what you have tried for the DB port (8889), I am going to ‘guess’ you are using MAMP on a Mac, as that is it’s default DB port. If this is in fact the case, this is what you need in wp-config.php, using the default MAMP values:

    DB name: whatever you named it (no spaces)

    DB user: root <the default MAMP DB USER name>

    DB password: root <the default MAMP DB USER pwd>

    DB hostname: localhost or 127.0.0.1

    Also, if you are on a Mac and you used TextEdit to edit the config file, be careful that it didn’t change the single quotes, as can happen if the settings are such. That is why it is always advisable to use a plain text editor such as Text Wrangler to do these edits.

    Thread Starter aegirr

    (@aegirr)

    Hi, thanks for the tips, and sorry about lack of information in my original post.

    I am running a PC with XAMPP

    LebCit: I already tryed all the tips from this site, but still getting error.

    The strange thing is I have a similar installation on another PC, and there this works fine. I actually tryed to backup wordpress from that PC, and restore the same installation on the other PC, but that did not work.

    So the theory is that there is nothing wrong with the wordpress-configuration, but something is wrong on the other PC. But what? What could block the connection between MySQL and WordPress, other than misconfigured wp-config.php and misconfigured database?

    Thread Starter aegirr

    (@aegirr)

    I still cannot install WordPress locally. Here is more informastion about the situation.

    I am using Windows 7. I can see in the XAAMP Control Panel that the web server and the database is running. The Control Panel tells med that the database is using the port number 3306, but this line in wp-config.php does not work:

    define(‘DB_HOST’, ‘127.0.0.1:3306’);

    What is stopping WordPress from contacting the database? Any ideas?

    Hi,
    Can you make sure that your localhost is working by typing https://localhost/ in your browser after running XAMPP.

    Did you use manual installation? If yes then use these:

    /** The name of the database for WordPress */
    define('DB_NAME', 'dbname');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', '');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');

    Also check your table prefix:

    $table_prefix  = 'wp_';
    Thread Starter aegirr

    (@aegirr)

    icraftzone: Wow, thanks, now it works!

    I guess this works because there already is a user named root in the database, but why doesnt this work (like it did on the old PC) with a user that I create manually? By the way, isnt this a security issue?

    No! since you are working on your local machine so no security issue and we almost all do like that ??

    cheers

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.