Support » Localhost Installs » First time with error Unable to connect to database

  • Hello community, I am writing this post because this is the forst time I got issues with a wordpress installation on a new server, I edited the wp-config.php file with the needed information and I get the error.

    I am using a red hat server that has this mysqld path :/var/run/mysqld/mysqld.sock so I changed the default localhost in line define(‘DB_HOST’, ‘localhost:/var/run/mysqld/mysqld.sock’); according to instrucionts at

    I do have the correct username and password, what could be wrong?

    *Extra info: In that server there are other cms´s including drupal (I didnt setup those) and I checked that in the configuration file it has the following:

    * Database URL format:
    * $db_url = ‘mysql://username:password@localhost/databasename’;
    * $db_url = ‘mysqli://username:password@localhost/databasename’;
    * $db_url = ‘pgsql://username:password@localhost/databasename’;

    $db_url = ‘mysqli://’;

    (Im not posting the real values for obvious reasons)

    If anyone has some idea to help me it would be great, thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi


    Forum Moderator

    That’s not from the WordPress wp-config.php file.

    hello esmi, what do you mean with thats not from the WordPress config file? If you reffer to the lines of database URL format they are from a drupal installation as I posted above.



    Forum Moderator

    That’s what I meant. I’m not sure why you posted them.

    I posted them like an “extra info” just in case someone could have a an idea why they are working fine (establishing communication to database) and wordpress not. I have installed a lot of wordpress sites without poblems since 2009 in differente servers and not sure why I cant on this one.



    Forum Moderator

    The only think I can suggest is that you verify the database details with the hosts.

    I am the host..I manage the server, unfortunately I dont have too much experience as a server admin.

    Register a new database using your hosting’s Cpanel and then input the credentials of that database

    Hello Marvel Labs, I dont have a cpanel but shell access to the server, i already tried what you suggested but no still no luck.

    I have figured out that in my etc/hosts file I have a list of ip addresses with domain names (including the one I am trying to install wordpress) like so:

    # Do not remove the following line, or various programs
    # that require network functionality will fail. domainame1 localhost.localdomain localhost domainame1 domainame2 domainame3 domainame4
    ::1 localhost6.localdomain6 localhost6

    Where domain name (1,2,3 etc) are the domain names of the websites we have hosted on that server.

    The domain name were I would like to install wordpress is listed there however, I am trying to install wordpress on a subdirectory of that domainame (domainame/wordpress) since the domain name already has another cms (drupal).

    In the wp config file I tried using localhost and the ips and

    i also tried using the define(‘DB_HOST’, ‘localhost:/var/run/mysqld/mysqld.sock’);

    I still get the error establishing database connection

    Does someone have experience working with own linux server that can guide me, maybe I am skipping a step or something.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘First time with error Unable to connect to database’ is closed to new replies.