Topic: Database connection issue

I'm a new user so firstly I'd like to say what an excellent piece of software FrontAccounting is - Thanks to all contributors!

I've just moved to a new server and am struggling to get a connection to the mysql database. I've checked that the user and password are correct.

I can access the database from the command line but have to specify port and protocol so I use:
mysql -P 12345 -u user_name -p --protocol=tcp (where 12345 is the port number)

Is there any place I can specify the port number and protocol in the FA setup?

Re: Database connection issue

Having rummaged around in the code, I found that the problem stemmed from the php function mysql_connect.
The solution was here: http://stackoverflow.com/questions/6366192/specifying-protocol-in-mysql-connect-php

If you specify your server and port as localhost:12345 the php will use a socket.
The fudgearound is to specify it as 127.0.0.1:12345 then php will use TCP/IP.

Excellent. FA's now up and running on my new server!

Re: Database connection issue

You need to modify the string according to mysqli connections (for FA 2.4.1) string format, which is

mysqli_connect(host,username,password,dbname,port,socket);

So go to the  "connect_db_mysqli.inc" file under
..\public_html\frontaccounting\includes\db\connect_db_mysqli.inc

Line 203

$db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);

change to

$db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"],NULL,3307);
Where 3307 is your mysql port.

Re: Database connection issue

Maybe it is time the array $db_connections in config_db.php now has a new element dbport implemented in create/edit/list new company and in the connect files.

Re: Database connection issue

@joe / @itronics: Thanks for the commit that now allows non standard db ports in FA 2.4.x.

Gracefully degrades to accommodate old config_db.php files that do not have the port element in each connection instance.

For later versions of MySQL (v5.7+) turn off strict mode with:

SET @@global.sql_mode= '';

This will accomodate zero values in dates.

Post's attachments

FA24_DBPortAdded.png 24.6 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.