Search code examples
phpdatabaseconfigsilverstripesilverstripe-4

SilverStripe 4: Where is the database configuration?


I've been reading the doc's on this but totally confused. My mysite/_config.php file is empty after install. Where do I find the database settings for the site such as username, database name and password?

Doc's page here: https://docs.silverstripe.org/en/4/changelogs/4.0.0/#env


Solution

  • You need to define them in a .env file, see the .env.example file which comes with the installer for a template.

    The example (from the link you posted):

    ## Environment {#environment}
    SS_ENVIRONMENT_TYPE="dev"
    SS_DEFAULT_ADMIN_USERNAME="admin"
    SS_DEFAULT_ADMIN_PASSWORD="password"
    SS_BASE_URL="http://localhost/"
    
    ## Database {#database}
    SS_DATABASE_CHOOSE_NAME="true"
    SS_DATABASE_CLASS="MySQLDatabase"
    SS_DATABASE_USERNAME="root"
    SS_DATABASE_PASSWORD=""
    SS_DATABASE_SERVER="127.0.0.1"
    

    Note that SS_DATABASE_CHOOSE_NAME will determine a DB name automatically for you and create it. If you want to use a specific DB name you can ignore this line and set SS_DATABASE_NAME instead.