Ready to get started?Download WordPress


First time with error Unable to connect to database (10 posts)

  1. Euclides
    Posted 1 year ago #

    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 http://codex.wordpress.org/Editing_wp-config.php

    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://USERNAME:PASSWORD@xx.xxx.xx.xxx/DATABASENAME';

    (Im not posting the real values for obvious reasons)

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

  2. esmi
    Forum Moderator
    Posted 1 year ago #

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

  3. Euclides
    Posted 1 year ago #

    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.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

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

  5. Euclides
    Posted 1 year ago #

    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.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

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

  7. Euclides
    Posted 1 year ago #

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

  8. Marvel Labs
    Posted 1 year ago #

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

  9. Euclides
    Posted 1 year ago #

    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.

  10. Euclides
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic