Support » Installing WordPress » Error establishing a database connection

  • Dear…

    Well I was very enthusiastic about wordpress and bought the required services I need for wordpress, after transferring all the files to my FTP I get the classic error: Error establishing a database connection. I read the forums and I am 100% I used the right username, password, database name and hostname…

    Please help me, really getting insane at the moment why it doesn’t work… (btw checked my mySQL services etc everything is up and running I really don’t get it)…

Viewing 15 replies - 1 through 15 (of 36 total)
  • Moderator kmessinger


    Error establishing a database connection
    This is not a random error. You must have something wrong. Recheck your wp-config.php file and make sure it is uploaded to the server.

    // ** MySQL settings ** //
    define('DB_NAME', 'mydatabasename');    // The name of the database
    define('DB_USER', 'username');     // Your MySQL username
    define('DB_PASSWORD', 'password'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value

    Like I said my friend I am 100% sure this is right! checked it around 14 times and also reuploaded the wp-config.php file several times to make sure I didn’t make any stupid mistake 🙁

    I have the same problem. ‘My database name’ seems straight forward but username gives me a problem because I do not think I was asked for a user name when I setup the mySQl database. My isp says I should use the database name as the user name,

    I also have the same problem. Have been in contact with my webhost and they are saying that my database name, username, password and host is qiute right. Still when I am going to install, i get the message that “this page can not be shown” and I have tried to upload all the files many times over. I would be very grateful if someone could be helpful

    I had this problem and found that switching between ‘local host’ and the ‘actual ip address’ can help.

    Moderator kmessinger


    You should be able to log on to your website and check your database name, password, etc. Whatever front-end your host provides should give you access and control of the db thru phpMyAdmin or something like that.

    I am not encouraging you to mess with your database but to confirm yourself the name, password, etc.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Like I said my friend I am 100% sure this is right!

    And like he said, it is not a random error.

    That error can only happen when:
    a) The web server cannot connect to the database.
    b) The information is not “100% right”.

    There really is no alternative answer to give you. Either the database is broken or the information you have put in is incorrect. To be more specific, only the hostname, username, or password can cause this error to be displayed (when the database name is incorrect, it will give you a “Can’t select database” error instead).

    If you need your host to fix it, you can tell them that the relevant PHP code to reproduce the problem is basically this:

    $host = 'hostname';
    $user = 'username';
    $password = 'password';
    $dbh = @mysql_connect($host, $user, $password);
    if (!$dbh) {
    echo "Error establishing a database connection";
    } else {
    echo "Database connection successful";

    That’s basically the same thing as what WordPress is attempting to do. If that works, WordPress will work.

    I changed the local host and get the following

    ?php // **MySQL settings ** // defie(‘DB_NAME’, ‘acidreflux’); // The name of the database define(‘DB_USER’, acidreflux); // Your MySQL username define(‘DB_PASSWORD’, ‘REMOVED’); // …and password define(‘DB_HOST’, ‘ // 99% chance you won’t need to change this value define(‘DB_CHARSET’, ‘utf8’); define(‘DB_COLLATE’, ”); // You can have multiple installations in one database if you give each a unique prefix $table_prefix = ‘wp_’; // Only numbers, letters, and underscores please! // Change this to localize WordPress. A corresponding MO file for the // chosen language must be installed to wp-content/languages. // For example, install to wp-content/languages and set WPLANG to ‘de’ // to enable German language support. define (‘WPLANG’, ”); /* That’s all, stop editing! Happy blogging. */ define(‘ABSPATH’, dirname(__FILE__).’/’); require_once(ABSPATH.’wp-settings.php’); ?>
    Fatal error: Call to undefined function: wp() in /home/domains/ on line 18

    How do I fix?


    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    You broke the file somehow. Start again with a fresh copy of the sample file and use a standard text editor. Notepad will work.

    You can also upload wordpress to your host without editing the config.php file. I forgot to do that once and It allowed me to input the database information through my web browser

    I had the same problem, where the error message says that it can’t contact the database server at localhost.
    Any suggestions?

    I had the same problem, but then I changed ‘localhost’ and everything worked perfectly.
    My host was a series of numbers, but I guess it doesn’t has to be.

    Moderator kmessinger


    This message
    “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.”
    does NOT mean “localhost” is incorrect. There is a “99% chance you won’t need to change this value.”

    First exclude all other factors like missppelling, to many blank spaces, all other HUMAN errors. 99 times out of a hundred, the error will be operator error.

    I have a Linux PHP account hosted by GoDaddy. I was getting the same errors until I changed “localhost” to the hostname listed in my SQL database control panel on GoDaddy. Everything immediately started working perfectly. The entire process took about 15 minutes. Uploading the files was about 5 minutes of that. Hope this helps.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    That “99%” seems like crap to me. For most hosts, the database server is separate from the webserver. If you are running on a dedicated box, sure, localhost makes sense. But for 99% of the shared hosting, the mysql box will be separate, and it will not be “localhost” for that parameter.

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