Elgg 1.11.2 fresh install error on linux

I am getting this error

[25-May-2015 13:46:03 America/Chicago] Exception #1432579563: exception 'DatabaseException' with message 'Elgg couldn't connect to the database using the given credentials. Check the settings file.' in /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php:147

Stack trace:

#0 /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php(123): Elgg\Database->establishLink('readwrite')

#1 /home/myusername/public_html/elgg/engine/lib/elgglib.php(1838): Elgg\Database->setupConnections()

#2 [internal function]: _elgg_engine_boot('boot', 'system', NULL)

#3 /home/myusername/public_html/elgg/engine/classes/Elgg/EventsService.php(56): call_user_func_array('_elgg_engine_bo...', Array)

#4 /home/myusername/public_html/elgg/engine/lib/elgglib.php(571): Elgg\EventsService->trigger('boot', 'system', NULL)

#5 /home/myusername/public_html/elgg/engine/start.php(68): elgg_trigger_event('boot', 'system')

#6 /home/myusername/public_html/elgg/index.php(55): require_once('/home/myusername/...')

#7 {main}

[25-May-2015 13:46:03 America/Chicago] PHP WARNING: 2015-05-25 13:46:03 (CDT): "mysql_real_escape_string(): Access denied for user 'myusername'@'localhost' (using password: NO)" in file /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php (line 651)

[25-May-2015 13:46:03 America/Chicago] PHP WARNING: 2015-05-25 13:46:03 (CDT): "mysql_real_escape_string(): A link to the server could not be established" in file /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php (line 651)

[25-May-2015 13:46:03 America/Chicago] Exception #1432579563 : fatal error in exception handler : Connection to database was lost.

  • "Elgg couldn't connect to the database using the given credentials. Check the settings file."

    Are your credentials correct?

  • yes. It was written like this $CONFIG->dbhost = '{{localhost}}'; and now I changed to this $CONFIG->dbhost = 'localhost'; and now I am receiving another error. May be it is a bug I do not know. What is this for? $CONFIG->exception_include = ''; This is written at the end of the settings.php file. Do i also have to put something in Database.php? Following is the error.

    [25-May-2015 20:39:43 America/Chicago] Exception #1432604383: exception 'InstallationException' with message 'Unable to handle this request. This site is not configured or the database is down.' in /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php:595
    Stack trace:

    [25-May-2015 20:39:43 America/Chicago] Exception #1432604383 : fatal error in exception handler : Table 'myusername_elgg.elgg_config' doesn't exist

     QUERY: SELECT value FROM elgg_config
                WHERE name = 'cookies' AND site_guid = 0

  • 1.11.2 was released on 25th of may. May be there is a bug. I am saying it because to check, I installed wordpress and it was successful. Waiting for reply.

  • Can you post your settings file here? (w\o password, of course)

  • <?php
    /**
     * Defines database credentials.
     *
     * Most of Elgg's configuration is stored in the database.  This file contains the
     * credentials to connect to the database, as well as a few optional configuration
     * values.
     *
     * The Elgg installation attempts to populate this file with the correct settings
     * and then rename it to settings.php.
     *
     * @todo Turn this into something we handle more automatically.
     * @package    Elgg.Core
     * @subpackage Configuration
     */

    global $CONFIG;
    if (!isset($CONFIG)) {
        $CONFIG = new \stdClass;
    }

    /*
     * Standard configuration
     *
     * You will use the same database connection for reads and writes.
     * This is the easiest configuration, and will suit 99.99% of setups. However, if you're
     * running a really popular site, you'll probably want to spread out your database connections
     * and implement database replication.  That's beyond the scope of this configuration file
     * to explain, but if you know you need it, skip past this section.
     */

    /**
     * The database username
     *
     * @global string $CONFIG->dbuser
     */
    $CONFIG->dbuser = '{{example_elgg}}';

    /**
     * The database password
     *
     * @global string $CONFIG->dbpass
     */
    $CONFIG->dbpass = '{{password}}';

    /**
     * The database name
     *
     * @global string $CONFIG->dbname
     */
    $CONFIG->dbname = '{{example_elgg}}';

    /**
     * The database host.
     *
     * For most installations, this is 'localhost'
     *
     * @global string $CONFIG->dbhost
     */
    $CONFIG->dbhost = '{{localhost}}';

    /**
     * The database prefix
     *
     * This prefix will be appended to all Elgg tables.  If you're sharing
     * a database with other applications, use a database prefix to namespace tables
     * in order to avoid table name collisions.
     *
     * @global string $CONFIG->dbprefix
     */
    $CONFIG->dbprefix = '{{elgg_}}';

    /**
     * Multiple database connections
     *
     * Elgg supports master/slave MySQL configurations. The master should be set as
     * the 'write' connection and the slave(s) as the 'read' connection(s).
     *
     * To use, uncomment the below configuration and update for your site.
     */
    //$CONFIG->db['split'] = true;

    //$CONFIG->db['write']['dbuser'] = "";
    //$CONFIG->db['write']['dbpass'] = "";
    //$CONFIG->db['write']['dbname'] = "";
    //$CONFIG->db['write']['dbhost'] = "";

    //$CONFIG->db['read'][0]['dbuser'] = "";
    //$CONFIG->db['read'][0]['dbpass'] = "";
    //$CONFIG->db['read'][0]['dbname'] = "";
    //$CONFIG->db['read'][0]['dbhost'] = "";
    //$CONFIG->db['read'][1]['dbuser'] = "";
    //$CONFIG->db['read'][1]['dbpass'] = "";
    //$CONFIG->db['read'][1]['dbname'] = "";
    //$CONFIG->db['read'][1]['dbhost'] = "";

    /**
     * Memcache setup (optional)
     * This is where you may optionally set up memcache.
     *
     * Requirements:
     *     1) One or more memcache servers (http://www.danga.com/memcached/)
     *  2) PHP memcache wrapper (http://php.net/manual/en/memcache.setup.php)
     *
     * Note: Multiple server support is only available on server 1.2.1
     * or higher with PECL library > 2.0.0
     */
    //$CONFIG->memcache = true;
    //
    //$CONFIG->memcache_servers = array (
    //    array('server1', 11211),
    //    array('server2', 11211)
    //);


    /**
     * Better caching performance
     *
     * Configuring the location of your data directory and enabling simplecache in
     * the settings.php file improves caching performance. It allows Elgg to skip
     * connecting to the database when serving cached JavaScript and CSS files. If
     * you uncomment and configure these settings, you will not be able to change
     * them from the Elgg advanced settings page.
     */
    //$CONFIG->dataroot = "";
    //$CONFIG->simplecache_enabled = true;


    /**
     * Cookie configuration
     *
     * Elgg uses 2 cookies: a PHP session cookie and an extended login cookie
     * (also called the remember me cookie). See the PHP manual for documentation on
     * each of these parameters. Possible options:
     *
     *  - Set the session name to share the session across applications.
     *  - Set the path because Elgg is not installed in the root of the web directory.
     *  - Set the secure option to true if you only serve the site over HTTPS.
     *  - Set the expire option on the remember me cookie to change its lifetime
     *
     * To use, uncomment the appropriate sections below and update for your site.
     *
     * @global array $CONFIG->cookies
     */
    // get the default parameters from php.ini
    //$CONFIG->cookies['session'] = session_get_cookie_params();
    //$CONFIG->cookies['session']['name'] = "Elgg";
    // optionally overwrite the defaults from php.ini below
    //$CONFIG->cookies['session']['path'] = "/";
    //$CONFIG->cookies['session']['domain'] = "";
    //$CONFIG->cookies['session']['secure'] = false;
    //$CONFIG->cookies['session']['httponly'] = false;

    // extended session cookie
    //$CONFIG->cookies['remember_me'] = session_get_cookie_params();
    //$CONFIG->cookies['remember_me']['name'] = "elggperm";
    //$CONFIG->cookies['remember_me']['expire'] = strtotime("+30 days");
    // optionally overwrite the defaults from php.ini below
    //$CONFIG->cookies['remember_me']['path'] = "/";
    //$CONFIG->cookies['remember_me']['domain'] = "";
    //$CONFIG->cookies['remember_me']['secure'] = false;
    //$CONFIG->cookies['remember_me']['httponly'] = false;


    /**
     * Use non-standard headers for broken MTAs.
     *
     * The default header EOL for headers is \r\n.  This causes problems
     * on some broken MTAs.  Setting this to true will cause Elgg to use
     * \n, which will fix some problems sending email on broken MTAs.
     *
     * @global bool $CONFIG->broken_mta
     */
    $CONFIG->broken_mta = false;

    /**
     * Disable the database query cache
     *
     * Elgg stores each query and its results in a query cache.
     * On large sites or long-running scripts, this cache can grow to be
     * large.  To disable query caching, set this to true.
     *
     * @global bool $CONFIG->db_disable_query_cache
     */
    $CONFIG->db_disable_query_cache = false;

    /**
     * Minimum password length
     *
     * This value is used when validating a user's password during registration.
     *
     * @global int $CONFIG->min_password_length
     */
    $CONFIG->min_password_length = 6;

    /**
     * This is an optional script used to override Elgg's default handling of
     * uncaught exceptions.
     *
     * This should be an absolute file path to a php script that will be called
     * any time an uncaught exception is thrown.
     *
     * The script will have access to the following variables as part of the scope
     * global $CONFIG
     * $exception - the unhandled exception
     *
     * @warning - the database may not be available
     *
     * @global string $CONFIG->exception_include
     */
    $CONFIG->exception_include = '';

  • The last error was generated after I removed {{ }} and only used $CONFIG->dbuser = 'example_elgg';

  • Edit this part:

    /**
     * The database username
     *
     * @global string $CONFIG->dbuser
     */
    $CONFIG->dbuser = '{{example_elgg}}';

    /**
     * The database password
     *
     * @global string $CONFIG->dbpass
     */
    $CONFIG->dbpass = '{{password}}';

    /**
     * The database name
     *
     * @global string $CONFIG->dbname
     */
    $CONFIG->dbname = '{{example_elgg}}';

    /**
     * The database host.
     *
     * For most installations, this is 'localhost'
     *
     * @global string $CONFIG->dbhost
     */
    $CONFIG->dbhost = '{{localhost}}';

    /**
     * The database prefix
     *
     * This prefix will be appended to all Elgg tables.  If you're sharing
     * a database with other applications, use a database prefix to namespace tables
     * in order to avoid table name collisions.
     *
     * @global string $CONFIG->dbprefix
     */
    $CONFIG->dbprefix = '{{elgg_}}';

     

    With right code:

    /**
     * The database username
     *
     * @global string $CONFIG->dbuser
     */
    $CONFIG->dbuser = 'example_elgg';

    /**
     * The database password
     *
     * @global string $CONFIG->dbpass
     */
    $CONFIG->dbpass = 'password';

    /**
     * The database name
     *
     * @global string $CONFIG->dbname
     */
    $CONFIG->dbname = 'example_elgg';

    /**
     * The database host.
     *
     * For most installations, this is 'localhost'
     *
     * @global string $CONFIG->dbhost
     */
    $CONFIG->dbhost = 'localhost';

    /**
     * The database prefix
     *
     * This prefix will be appended to all Elgg tables.  If you're sharing
     * a database with other applications, use a database prefix to namespace tables
     * in order to avoid table name collisions.
     *
     * @global string $CONFIG->dbprefix
     */
    $CONFIG->dbprefix = 'elgg_';

     

    Of course, you need to add YOUR own:

    • dbuser  (usually, root)
    • dbpass
    • dbname (create new database and add its name here)
    • dbhost (usually, localhost)
    • dbprefix (usually, elgg_)
  • I have tried it already. The last error I shared on this discussion was generated after I applied it. Here is the error again

    [25-May-2015 20:39:43 America/Chicago] Exception #1432604383: exception 'InstallationException' with message 'Unable to handle this request. This site is not configured or the database is down.' in /home/myusername/public_html/elgg/engine/classes/Elgg/Database.php:595
    Stack trace:

     

    [25-May-2015 20:39:43 America/Chicago] Exception #1432604383 : fatal error in exception handler : Table 'myusername_elgg.elgg_config' doesn't exist

     QUERY: SELECT value FROM elgg_config
                WHERE name = 'cookies' AND site_guid = 0

  • Let's start from the beginning:

    1- Delete your engine/settings.php file

    2 - Go to your-elgg-site/install.php

    3 - Watch my just created dumbed video Elgg Installation

    4 - Learn docs

    5 - Read about creating data folder, about creating MySQL database, about settings.php and .htaccess files

    Good luck!