$dolibarr_main_db_host issue with port


DOLIBARR ENVIRONMENT
- Version: 10.0.3
- Operating System: Linux (Synology DSM 6.2.2-24922 Update 3)
- Web Server: nginx 1.15.7
- PHP: Dolibarr shows 7.3.7, but phpMyAdmin shows 5.6.40
- Database: MariaDB 10.3.11
- URL(s): index.php?mainmenu=home&leftmenu=home
admin/tools/dolibarr_export.php?mainmenu=home&leftmenu=admintools


During setup the only way I could get Dolibarr to connect to MariaDB was to set $dolibarr_main_db_host to include the port number (i.e. localhost:3307). $dolibarr_main_db_port was also set to 3307. I found this fix in a forum from another using running Dolibarr on Synology DSM.

This causes backups to fail using mysqldump with the error:
Error : Failed to run external command. Check it is available and runnable by your PHP server. If PHP Safe Mode is enabled, check that command is inside a directory defined by parameter safe_mode_exec_dir.

The issue is not actually safe mode, when I run the backup command using SSH I get the following error:

/usr/local/mariadb10/bin/mysqldump dolibarr [color=#ff0000]-h localhost:3307[/color] -u doli -P 3307 -l --single-transaction --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 -p"********************************"

mysqldump: Got error: 2005: “Unknown MySQL server host ‘localhost:3307’ (-2)” when trying to connect

The issue is the hostname, I get a successful dump when I amend the hostname and run in SSH

/usr/local/mariadb10/bin/mysqldump dolibarr [color=#ff0000]-h localhost[/color] -u doli -P 3307 -l --single-transaction --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 -p"********************************"

I tried changing $dolibarr_main_db_host in conf.php , but without the port included in the host variable Dolibarr will not launch and I get a php error.

I tried editing core/class/utils.class.php to use a new global variable $dolibarr_main_db_host_for_backup, and added $dolibarr_main_db_host_for_backup to conf.php , but it didn’t work, it was producing the backup command with no hostname:

/usr/local/mariadb10/bin/mysqldump dolibarr [color=#ff0000]-h [/color] -u doli -P 3307 -l --single-transaction --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 -p"********************************"

I don’t actually know php so I probably did something wrong in my attempted fix. Any help with a workaround for this would be greatly appreciated.

dolibarr_main_db_host should be localhost
and
dolibarr_main_db_port should be 3307

So the question is why can’t you launch dolibarr with this setup. Which error do you have ?

Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /volume1/web/dolibarr/htdocs/core/db/mysqli.class.php on line 205 Call Stack: 0.0001 408264 1. {main}() /volume1/web/dolibarr/htdocs/index.php:0 0.0001 426488 2. require(’/volume1/web/dolibarr/htdocs/main.inc.php’) /volume1/web/dolibarr/htdocs/index.php:29 0.0016 434744 3. require_once(’/volume1/web/dolibarr/htdocs/master.inc.php’) /volume1/web/dolibarr/htdocs/main.inc.php:250 0.0021 640384 4. getDoliDBInstance() /volume1/web/dolibarr/htdocs/master.inc.php:120 0.0022 658736 5. DoliDBMysqli->__construct() /volume1/web/dolibarr/htdocs/core/lib/functions.lib.php:59 0.0022 658760 6. DoliDBMysqli->connect() /volume1/web/dolibarr/htdocs/core/db/mysqli.class.php:91 0.0022 659192 7. mysqli->__construct() /volume1/web/dolibarr/htdocs/core/db/mysqli.class.php:205 Xdebug: user triggered in /volume1/web/dolibarr/htdocs/core/lib/functions.lib.php on line 3826 Call Stack: 0.0001 408264 1. {main}() /volume1/web/dolibarr/htdocs/index.php:0 0.0001 426488 2. require(’/volume1/web/dolibarr/htdocs/main.inc.php’) /volume1/web/dolibarr/htdocs/index.php:29 0.0016 434744 3. require_once(’/volume1/web/dolibarr/htdocs/master.inc.php’) /volume1/web/dolibarr/htdocs/main.inc.php:250 0.0024 659352 4. dol_print_error() /volume1/web/dolibarr/htdocs/master.inc.php:124 0.0032 663520 5. xdebug_print_function_stack() /volume1/web/dolibarr/htdocs/core/lib/functions.lib.php:3826 DolibarrHasDetectedError.
InformationToHelpDiagnose:
Date: 20191114135054
Dolibarr: 10.0.3
PHP: 7.3.7
Server: nginx/1.15.7
OS: Linux MPE-NAS 3.10.105 #24922 SMP Wed Jul 3 16:37:24 CST 2019 x86_64
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36 OPR/64.0.3417.92

RequestedUrl: /
Referer:
MenuManager:

DatabaseTypeManager: mysqli
RequestLastAccessInError: ErrorNoRequestInError
ReturnCodeLastAccessInError: ErrorNoRequestInError
InformationLastAccessInError: ErrorNoRequestInError

Message: host=localhost, port=3307, user=doli, databasename=dolibarr, No such file or directory
XDebug informations:
File: /volume1/web/dolibarr/htdocs/main.inc.php
Line: 250
Function: