Re: Setup DB Connection Error

There is problem with connecting your MySql server. Looks like connection credentials wrong or the MySql server is down.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Setup DB Connection Error

Thanks for the response but Is not the database, as you can see the MariaDB logs I pasted, there is a successful connection and the db running. as you can see on the logs i tried on the application install and fail (LOG 96) but using the same credentials i could access to the database correctly BY SSH and mysql client (LOG 97).  also installed a wordpress pointing to same database with same credential  for testing and no problem with database, also the account have all privileges

I tried the script kvvaradha posted so long ago to test the db connection and was success, also tried the solution of redcone, but it did not work. So do not have now where to look out, I will appreciate what else i could check out to get the problem solved.


201221  3:49:05     96 Connect  fraccdbuser@localhost as anonymous on fraccdb
                    96 Connect  Access denied for user 'fraccdbuser'@'localhost' (using password: YES)
201221  3:49:41     97 Connect  fraccdbuser@localhost as anonymous on
                    97 Query    select @@version_comment limit 1
201221  3:49:57     97 Query    SELECT DATABASE()
                    97 Init DB  fraccdb
                    97 Query    show databases
                    97 Query    show tables
201221  3:50:01     97 Quit

Re: Setup DB Connection Error

FWIW, me too, and I found the problem. The connection is not using 3306 when it is not specified.

It looks like it is, but there could be a mistake in this line, or perhaps a non NULL value is being passed by the database connection in the install script.

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

FrontAccounting 2.4.9
PHP 7.3
MariaDB 10.3.18

Re: Setup DB Connection Error

I spoke too soon.

Adding 3306 does allow the installation to proceed to the next screen. The following message is displayed:

"All application preliminary requirements seems to be correct. Please press Continue button below."

However, clicking continue returns to the database login, and the same connection parameters no longer work. It is possible to get back to the preliminary requirements confirmation by trying once to login without 3306, and then again with.

There appears to be a fail in the logic check around the port number.

Re: Setup DB Connection Error

Your mariadb port no is different. Guess your hosting provider is using different port no for mariadb. Check with them to get it. Usually most of the MySql server configured with 3306.  And some servers they might changed port no for some other apps. So you have to get right port no for your mariadb and input here. With right port no, it will work.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Setup DB Connection Error

Still no solution, but perhaps this will save someone else a few steps.

I have a similar setup running correctly on another Apache server that ran FrontAccounting 2.4.6 on PHP versions 7.1 up to 7.4. It may have been installed on PHP 5.6, and later upgraded. I can no longer recall for certain but I believe it was installed on PHP 7.1.

Both databases are local to the server and have the exact same privileges, database names, etc.

MariaDB [(none)]> show grants for username@'localhost';
GRANT USAGE ON *.* TO 'username'@'localhost' IDENTIFIED BY PASSWORD '******'
GRANT ALL PRIVILEGES ON `username`.* TO 'username'@'localhost'

I took a look at changes in the code and found nothing significant in the following three files:

$ diff frontaccounting-2.4.9/includes/db/connect_db_mysqli.inc frontaccounting-2.4.6/includes/db/connect_db_mysqli.inc 
13c13
< define('SQL_MODE', 'STRICT_ALL_TABLES'); // prevents SQL injection with silent field content truncation
---
> define('SQL_MODE', ''); // STRICT_ALL_TABLES,NO_ZERO_IN_DATE ?

$ diff frontaccounting-2.4.9/includes/db/connect_db.inc frontaccounting-2.4.6/includes/db/connect_db.inc 
(no change)

$ diff frontaccounting-2.4.9/install/index.php frontaccounting-2.4.6/install/index.php
(no change)

Re: Setup DB Connection Error

kvvaradha wrote:

Your mariadb port no is different. Guess your hosting provider is using different port no for mariadb. Check with them to get it. Usually most of the MySql server configured with 3306.  And some servers they might changed port no for some other apps. So you have to get right port no for your mariadb and input here. With right port no, it will work.

It's my server on a rack 2 m to my left. Default port, 3306. This also doesn't explain why adding 3306 will get past the first database login to a confirmation screen, only to fail and loop back to the database login screen. Something is amiss.

33 (edited by guabeff 12/22/2020 06:40:19 pm)

Re: Setup DB Connection Error

Testing further i think i Just got the root of the problem, indeed there is something wrong with the file connect_db_mysqli.inc as gnurob mentioned, when you use a password on the user database that is 21 or more characters long this script fail in the setup, a password less than 21 character will connect successfully go to next steps and install the application.


I could prove that is the script failing and not the database, because i also test hardcoding the password  in the line 205 of the file connect_db_mysqli.inc, If you hardcode the password and run the setup no matter if  password is 21 o more characters long it will succeed.

I change this line

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

For this line

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

So in conclusion:
- There is something wrong in the logic of the code on the file connect_db_mysqli.inc at line 205 (db_create_db function), that is not passing the correct password to the database if password is 21 characters or more.

Workaround:
- Use a password less than 21 characters for the database user.

Hope this is could help, and some of the developers can test, confirm and fix this issue

Re: Setup DB Connection Error

Thank you guabeff. Good testing.

Continuing on this. I checked my password: only 10 characters. However, it contained an ampersand. On a hunch I replaced "&" with "a" and everything works. There is obviously some string sanitation going on that's breaking passwords (only enough, manually entering port 3306 will partially bypass it).

I replaced the "&" character with the letter "a", in my 10 character password, and everything works--it was only 10 characters.

Re: Setup DB Connection Error

MySQL host, username, password length restrictions in MySQL 5.5.36 is 60, 16 and 41 respectively but consider the real password length to be less as hashing payload exists. Do not directly try to change the field sizes of the various tables in the mysql db.

MySQL uses PASSWORD(str) to encrypt the cleartext password str. This hashed password string is stored in the mysql.user grant table with a CHAR(41) datatype.

Refer:
https://dev.mysql.com/doc/refman/5.7/en/user-names.html
https://stackoverflow.com/questions/7465204/maximum-mysql-user-password-length

The file create_coy.php in lines 331-335 has these size limits:

        text_row_ex(_("Host"), 'host', 30, 60);
        text_row_ex(_("Port"), 'port', 30, 60);
        text_row_ex(_("Database User"), 'dbuser', 30);
        text_row_ex(_("Database Password"), 'dbpassword', 30);
        text_row_ex(_("Database Name"), 'dbname', 30);

If such size limitations exist as indicated by the findings in this thread, then these sizes should be enforced here.

Re: Setup DB Connection Error

RedCone wrote:

I get the following error messages when trying to connect to the db:
mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in file: /var/www/html/includes/db/connect_db_mysqli.inc at line 206
mysqli_select_db() expects parameter 1 to be mysqli, boolean given in file: /var/www/html/includes/db/connect_db_mysqli.inc at line 208
mysqli_query() expects parameter 1 to be mysqli, boolean given in file: /var/www/html/includes/db/connect_db_mysqli.inc at line 213
Cannot connect to database. User or password is invalid or you have no permittions to create database.

I have read every thread I have found, but nothing seems to address this issue. One post suggested issues with PHP7, so I added a modification to revert back to PHP5.6. This did not make any difference. I've also read threads suggesting changes to the connect_db_mysqli.inc file, but my file already seems to include the proposed changes.

I've had no problem accessing MySQL via SSH, so I know it's running. Am I missing something obvious? Oh, and I'm using Ubuntu 16.04

Hoping for a solution...

I tried to install FA on a Synology NAS system.  Got stuck with exactly the same error messages, and done everything that I found in posts etc.  The NAS uses Maria DB (v10).  My solution was to set the MariaDB FTP option and then do the installation with the server being 127.0.0.1:3307, where 3307 is the default port number for ftp connections to the database.

Re: Setup DB Connection Error

Hi Folks,

Kudos to guabeff and gnurob; on a fresh install of 2.4.10, I can confirm that both situations are correct; password must be less than 21 characters long, *and* must not contain an ampersand.  Did not test other special characters, I just removed them all from the password, and got by that screen.

Re: Setup DB Connection Error

Did not find the issue reported in Mantis, so I created an entry there.