Topic: User or password is invalid or you have no permissions to create datab

Hi,

I'm new to XAMP and FrontAccounting and am having some issues when trying to install.  I've looked at the other posts that referred to this same error message:

Cannot connect to database. User or password is invalid or you have no permissions to create database.

But neither has helped me get over this first hurdle.

I have installed XAMPP for Windows 5.6.28 on my 64bit Windows 8.1 laptop.

I have IIS running as well so I changed the httpd.conf to Listen 81.

Version information:
Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
10.1.19-MariaDB

I manually created a new user, setting the Host Name to localhost and selected this check box: Create database with same name and grant all privileges.

Accessing the install page (http://localhost:81/frontaccounting/install/index.php) shows everything as OK on the first page.  When I hit continue and enter the server host as: 127.0.0.1:81, put in my database user, password and database name (I'm 99% sure I've got these details correct) then hit continue, it takes a few minutes before the above error message is displayed.

I'd appreciate any advice on troubleshooting this.

Re: User or password is invalid or you have no permissions to create datab

Turn off strict mode on PHP 5.6+ as date and time fields will otherwise not recognize zero values.

Re: User or password is invalid or you have no permissions to create datab

I have the same issue. My php.ini file states

; error_reporting
;   Default Value: E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

From what I can find other places, this should have solved the issue, but it doesn't. What am I missing?

Re: User or password is invalid or you have no permissions to create datab

Try to explicitly put in:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Re: User or password is invalid or you have no permissions to create datab

I have tried this solution, and variations thereof, but I still get the message "Cannot connect to database. User or password is invalid or you have no permissions to create database."

Re: User or password is invalid or you have no permissions to create datab

@redcone  The database uses port 3306 not port 81.  3306 is the default, so you can just leave the :80 off the database server setting.  So 127.0.0.1 should be fine.

Cambell https://github.com/cambell-prince

Re: User or password is invalid or you have no permissions to create datab

@cambell, that part of the question was asked by @FCazabon. However, I've tried with 127.0.0.1 and localhost respectively, and still am not able to access the db.

Re: User or password is invalid or you have no permissions to create datab

Check the config_db.php file if your db access credentials for the target company are okay and the privileges have been flushed for it to come into effect.

Re: User or password is invalid or you have no permissions to create datab

@redcone How did you create the database, user and password?  Perhaps you can test that you can access the database with something like phpmyadmin.

Cambell https://github.com/cambell-prince

Re: User or password is invalid or you have no permissions to create datab

So we figured it out. We were able to connect with the db just fine from several other methods. The issue ended up being caused by what seems like a error in the connect_db_mysqli.inc file where it was skipping the

mysqli_select_db($db, $connection["dbname"]);

We changed it to

{
    global $db;

    $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"], "",
        !empty($connection["port"]) ? $connection["port"] : 3306); // default port in mysql is 3306

    //If no name is selected we will not be able to select a database nor create one just return
    if (!$connection["dbname"])
        return 0;
    
    //Try and select the specified database
    $selectedDB = mysqli_select_db($db, $connection["dbname"]);

    //If the db doesn't exist create the database
    if (!$selectedDB)
    {
        $sql = "CREATE DATABASE IF NOT EXISTS `" . $connection["dbname"] . "`"
            . " DEFAULT COLLATE '" . get_mysql_collation($connection["collation"]) . "'";

        if (!mysqli_query($db, $sql) || !mysqli_select_db($db, $connection["dbname"]))
            return 0;
    } else {
        //else just use the selected db and ensure that the collation is set correclty
         if ($selectedDB)
         {
            if (!db_set_collation($db, $connection["collation"]))
            {
                echo mysqli_error($db);
                return 0;
            }
        }
        else
            return 0;
    }
    return $db;
}

And now it works.