Problem with DB Connection

Hi all,

Firt of all sorry for my english, I hope to be clear.
I need your help, I'm trying to create a social network with Elgg in local and I have problems with the connection with the DB.

When I installed the following message

"Elgg could not connect to the database using the credentials Given. Check the settings file."

I followed all the steps described on the site but I have some problem with the settings of php.ini and settings.php file.
I created a DB with MySQL Workbench (5.5.19) installed to c:/Program Files/MySQL
I created the DB called "elgg", user called "admin" and password "admin" using SQL commands

CREATE DATABASE elgg;
CREATE USER admin IDENTIFIED BY 'admin';
GRANT ALL ON elgg.* to elgg;

The two files php.ini and settings.php are configured in this way:

SETTINGS.PHP
$CONFIG->dbuser = 'admin';

$CONFIG->dbpass = 'admin';

$CONFIG->dbname = 'elgg';

$CONFIG->dbhost = 'localhost';

$CONFIG->dbprefix = 'elgg';

--------------
PHP.INI
mysql.default_port = 3306

mysql.default_socket = /tmp/mysql.sock

mysql.default_host = "localhost"

mysql.default_user = "admin"

mysql.default_password = "admin"
---------------


I created an empty file "mysql.sock" in the "temp" folder in the localhost home of Apache because it does not exist.

What is wrong?

Thanks a lot!

  • GRANT ALL ON elgg.* to elgg;

    You granted privileges to the user "elgg", not "admin"

  • Thanks Cash, I changed the grants with

    GRANT ALL ON elgg.* to admin;

    but the issue is still present.

    The file settings are correct ?

    I have to install MySQL in the same path of Elgg ?

  • Google how to create a user and add privileges. There are plenty of tutorials out there. I think you have an issue with not including the host for the user.

  • I changed it, I dropped the user admin and re-created it in this way

    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';

    now I have another issue

    Elgg couldn't select the database 'elgg', please check that the database is created and you have access to it.

  • You can create the user on the fly. Try this

    1. use mysql;
    2. create database elgg;
    3. GRANT ALL PRIVILEGES ON elgg.* to admin@localhost IDENTIFIED BY 'admin';
    4. flush privileges;

    You might also want to add an underscore in Elgg's settings.php in this line:

    $CONFIG->dbprefix = 'elgg_';

    If it still doesn't work, your mysql server might not be accessible at all. Have you tested, if the server is accessible in general?

  • I tried to grant all privilege on the user admin (also with MySql Server Access Management) but the issue is still

    Elgg couldn't select the database 'elgg', please check that the database is created and you have access to it.

    Any other ideas ?

    how can I test if the server is accessible in general ?

  • I have just tried with SQLDeveloper and the DB elgg is accessible.

    So there is something wrong in the settings file...please help!!!!

  • Hi I am having problems here too, on apache.

    Fatal Error.

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

     

    Now I have done two things, to test, firstly I added to the end of settings.php

    php>

    and all I got was a completely blank screen.

    So I removed that and now I get the abovementioned error message.

    My databases are fine. Is it that my dbpass includes characters???


  • @sugarplum:sorry we didnt understand that. the settings.php page should look like below

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

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

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

    /**
     * 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 = 'prefix_';

  • I have that experience as you guys mentioned above:

    Fatal Error.
    Elgg couldn't connect to the database using the given credentials. Check the settings file.

    I don't know why I experience it because I haven't done any changes since it was running with no error. The error appeared only after I have a few people signing in to my site with their Facebook accounts that I have installed Facebook API mod.

    I was a bit nervous and run upgrade.php then the error disappeared. But I'm concern about this error will come up again anytime soon or often. It would be greatly appreciated if anyone could advice about further information on that error and how to fix it.

    Thank you.