Jump to:

22979 Posts in 11808 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Lost $databaseConfig in _config.php

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1831 Views
  • lennert
    Avatar
    Community Member
    4 Posts

    Lost $databaseConfig in _config.php Link to this post

    I changed the pw for my MYSQL database user (in retrospect I shouldn't have done that), but when I wanted to edit my database settings in _config.php to my surprise there was no $databaseConfig defined in the file. Have no _environment file so I'm wondering where I can find these settings.

    Have inherited this site from someone else so I'm not a Silverstripe expert. Any help would be appreciated.
    Using SS 2.3.1

    Lennert

  • lennert
    Avatar
    Community Member
    4 Posts

    Re: Lost $databaseConfig in _config.php Link to this post

    One thing I should have added:

    Tried adding $databaseConfig to _config.php but that didn't help. Still am getting "Website Error There has been an error".

  • lennert
    Avatar
    Community Member
    4 Posts

    Re: Lost $databaseConfig in _config.php Link to this post

    Went into dev mode and got the following error:

    =======
    [Warning] mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    GET /

    Line 35 in /nfs/c05/h01/mnt/69388/domains/darlingagency.com/html/sapphire/core/model/MySQLDatabase.php

    Source

    26    /**
    27     * Connect to a MySQL database.
    28     * @param array $parameters An map of parameters, which should include:
    29     * - server: The server, eg, localhost
    30     * - username: The username to log on with
    31     * - password: The password to log on with
    32     * - database: The database to connect to
    33     */
    34    public function __construct($parameters) {
    35       $this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password']);
    36       $this->active = mysql_select_db($parameters['database'], $this->dbConn);
    37       $this->database = $parameters['database'];
    38       if(!$this->dbConn) {
    39          $this->databaseError("Couldn't connect to MySQL database");
    40       }
    41
    Trace

    mysql_connect(localhost,db69388,xxxxxxx)
    Line 35 of MySQLDatabase.php
    MySQLDatabase->__construct(Array)
    Line 72 of DB.php
    DB::connect(Array)
    Line 187 of main.php

    ---
    (Changed pw). So it looks as if it's getting the correct info.
    Will continue digging.

  • lennert
    Avatar
    Community Member
    4 Posts

    Re: Lost $databaseConfig in _config.php Link to this post

    Alright fixed it myself.
    First of all I was able to find the correct call to the database.
    And secondly by making my $databaseConfig global I was able to override the default values which are hidden somewhere.

    Thanks for being an audience!

    1831 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.