Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation: Database port ignored when hostname is used instead of IP address #5510

Open
pgorod opened this issue Mar 15, 2018 · 7 comments
Labels
Area: Installation Issues & PRs related to the installation of the application Type:Bug Bugs within the core SuiteCRM codebase

Comments

@pgorod
Copy link
Contributor

pgorod commented Mar 15, 2018

Issue

According to a report on the forums, installer ignores a non-standard db_port in this format:

localhost:1234

but uses it correctly in this format:

127.0.0.1:1234

Note that there are performance issues associated with using 127.0.0.1 instead of localhost, it's not the same thing.

Expected Behavior

The port should be used in any case.

Possible Fix

This should be just a bug parsing the fields.

Steps to Reproduce

  1. Start fresh installation
  2. Type a database with a hostname, and with a non-standard port

Your Environment

  • SuiteCRM 7.10.1
  • PHP : 7.1.13
  • MariaDB : 10.2.10

I didn't test this myself, I am just reporting from what that user reported.

@gunnicom
Copy link
Contributor

Are you sure the port should be used in any case?
If you use "localhost", php will connect to mysql by unix socket, so no port involved there.
If you use "127.0.0.1" it will connect through tcp so there the port is needed.
I do not see how that is a bug, or if it can even be "fixed" somehow as that is the expected behaviour for mysql on php.

@pgorod
Copy link
Contributor Author

pgorod commented Mar 18, 2018

You are right. I am not seeing this correctly - I admit I was a bit misled by that Forum thread.

The only thing that perhaps might be improved is user "education". When people think of localhost:1234 it sounds like a normal, valid thing, you can use it as an URL in your browser, etc. It is not obvious that MySQL has this logic differentiating the way to connect via socket or TCP/IP...

I don't know, maybe I can just close the Issue and forget about this, or maybe we can try to come up with some way to handle this a bit better. For example, we could do this: if the user inputs localhost:1234, we change it internally to 127.0.0.1:1234 when we connect to MySQL. Do you think this makes any sense?

@gunnicom
Copy link
Contributor

gunnicom commented Mar 19, 2018

I think changing it internally will only make it worse. Some may have disabled socket or tcp connections and then you change it internally would make it harder to find what is wrong.
Maybe detecting the word "localhost" via javascript, and givving the user a hint that now mysql will be connected by socket, and if the user attached a port hinting him, that this is wrong.

@pgorod
Copy link
Contributor Author

pgorod commented Mar 19, 2018

From a previous discussion we had a few months ago, I changed the tooltip on that field to this:

 /var/www/html/install/language/en_us.lang.php:570:    
'LBL_DBCONFIG_MSG2' => 'Name of web server or machine (host) on which 
the database is located (such as www.mydomain.com). If installing locally, 
it\'s better to use \'localhost\' than \'127.0.0.1\', for performance reasons.', 

Maybe I could just add at the end:

Note that localhost will not allow use of a port number.

I wonder if this is valid for all DB engines, or just for MySQL?

@Dillon-Brown Dillon-Brown added the Area: Installation Issues & PRs related to the installation of the application label Jun 1, 2018
@samus-aran samus-aran added the Type:Bug Bugs within the core SuiteCRM codebase label Aug 31, 2020
@SuiteBot
Copy link

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/non-standard-mysql-socket-port/55519/10

@stfnet
Copy link

stfnet commented Jun 28, 2022

Hi all,
Here a proposed solution for using (non standard) sockets or in case of an environment with multiple instances of Mysql family server.

https://community.suitecrm.com/t/non-standard-mysql-socket-port/55519/9

Remember host parameter must be localhost.

Please note mysqli_connect gives precedence to TCP connection (and non standard port) if host=IP address. If host=localhost then sock parameter has precedence. This is why localhost + non-standard-port doesn't work, it uses standard sock.

@SuiteBot
Copy link

This issue has been mentioned on SuiteCRM. There might be relevant details there:

https://community.suitecrm.com/t/non-standard-mysql-socket-port/55519/11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Installation Issues & PRs related to the installation of the application Type:Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

6 participants