Support » Installing WordPress » InstallSTEP2: Error establishing db connection

  • alexb01


    This is the first time I try installing WordPress.
    Well some info first:
    1) I use Apache 1.3.33 server (yes it’s running. I’ve tested it)
    2) I use php 4.4.1 (running, tested)
    3) I use MySQL 4.1 Server (taskmanager says it’s running..)
    MySQL username= root
    MySQL password= foobar (just for the example)
    I go to \htdocs\ where the files must be uploaded, and I install WordPress 2.0 here \htdocs\www\wordpress\
    Firstly, as the Readme says I configure the wp-config-sample (and then rename it into wp-config.php)
    // ** MySQL settings ** //
    define(‘DB_NAME’, ‘MySQL’); // I’ve also tried to set ‘wordpress’ instead of MySQL
    define(‘DB_USER’, ‘root’); // Your MySQL username (default)
    define(‘DB_PASSWORD’, ‘foobar’); // …and password
    define(‘DB_HOST’, ‘localhost’); // Also tried to set it to

    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix = ‘wp_’; // Also tried to set ‘wp_1’ or ‘wp_blog’ or ‘wp_wordpress’ and ‘wp_wordpress_’

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-includes/languages.
    // For example, install to wp-includes/languages and set WPLANG to ‘de’
    // to enable German language support.
    define (‘WPLANG’, ”); // Didn’t change that

    /* That’s all, stop editing! Happy blogging. */

    define(‘ABSPATH’, dirname(__FILE__).’/’);

    As I said, I save the file as “wp-config.php”. Then I open \wp-admin\install.php and this is what I get:

    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

    * Are you sure you have the correct username and password?
    * Are you sure that you have typed the correct hostname?
    * Are you sure that the database server is running?

    If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    I’ve tried 10 times to install it but nothing. Oh.. One time, I managed to do “successfully” the installation, but when it opened the install.php the page was a mess(e.g. I saw a submit button and it’s value was <?php …). I opened PageSource and the PHP CODE was in PINK LETTERS. But from what I understood.. There was a problem (it’s the first time I face this). Let’s take some lines of code from the install.php
    define(‘WP_INSTALLING’, true);
    if (!file_exists(‘../wp-config.php’))
    die(“There doesn’t seem to be a <‘code’>wp-config.php<‘/code’> file… // I put the quotes between the code so that it will not be displayed as a CODE to you..
    I see that the “PINK CODE” (which must be php) STOPS when it faces a “>”.. So it stops at (at the '>').

    What must I do? At the moment, I don't even see the install.php . It just displays the ERROR page (can't connect to the db etc..)

    Thanks in advance guys.
    Meanwhile, I'll try to install an older version of WP.

    PS: Sorry for the HUGE post 😛

Viewing 10 replies - 1 through 10 (of 10 total)
  • moshu


    Did you create a database that is called “MySQL” or “wordpress”???
    It is there in the instructions somewhere that you have to create the database first, have the user to have ALL the privileges in that DB, and then the install is less than 5 minutes.

    [Explanation. “MySQL” is a software, where you can create X number of databases in it. Create one and use its name in the config file]



    Hello and thanks 🙂
    Ok, I’ve now created the database named ‘wordpress’. But here’s a f**king problem! I go to install.php (second step) and here’s what I get ->

    OMG! I open the sourcefile of install.php via TextPad and what I see is that the <?php stops everytime it faces a ‘ > ‘ !! Eg when there is something like this:
    $wpdb ->
    It stops at the > !!
    I try to do somethin similar to this in another file writing:
    <?php print ‘lose > r’; ?>
    And it is ok !!

    What should I do?



    What do you mean by “the PHP stops every time it hits a &gt?”

    Are you just referring to TextPad’s syntax highlighting or the PHP processing on your server?



    I refer Textpad only because I understood what is happening from there.
    Well, let’s say we have this:
    $wpdb->query(“INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, ‘”.$wpdb->escape(__(‘Blogroll’)).”‘)”);
    This is php code, so it started with <?php ..
    The php code STOPS when we put ?> right ?
    Well, here the php code stops at the $wpdb-> .. and generally it stops everytime it faces a > !

    So let’s say in the install.php there is this line:
    <?php print ‘dea > th’; ?>
    The browser will not display “dea > th”. It will display “<?php print ‘dea “

    And I repeat, this happens only in the install.php ! When I try to do this in another file created by me, it is ok! It stops only when it faces “?>” and not in every “>” !!!



    Can/will anybody help me?



    I personally haven’t had much luck with WP 2.0 myself, but I’m in the process of having the site that I’m having the problem with moved from a windows server to linux, so maybe that will help me.

    In working with WP 1.5.2, I did run across the dB connection error once. The config.php file says that most of the time you won’t have to change the hostname, but I found that for me, I did have to change that. I didn’t have to enter any server id’s or anything, just mysql hostname provided when I created my database.

    Don’t know whether that will help you or not.



    Somebody to solve my problem..?



    To me it looks like your wp-config file may not be set up properly, and you need to clear out your database tables before you try running the install.php again. Just a guess.




    If you haven’t solved this by now try this:

    I noticed that the config-sample.php file has windows control characters in it from the tar.gz file you can download. These will runin the file as its interpretted by php.

    When you can see them they look like “^M” at the end of each line.

    Use a text editor such as Notepad++ or ultraedit to see them, notepad on windows/wordpad are great at ruining these files by adding the invisible characters. This maybe your problem since you seem to have the other ducks in the rows.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘InstallSTEP2: Error establishing db connection’ is closed to new replies.