Bug #31002 specifying a tcp port on the command line may not always then use TCP...
Submitted: 13 Sep 2007 15:51 Modified: 9 Dec 2010 18:54
Reporter: Roger Pack Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.0.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: command line, tcp port

[13 Sep 2007 15:51] Roger Pack
Description:
When running the mysql client thus:
mysql --port=5900
it may still not use that port, but reverts to the defaults.  I.e. I expected it to act like
mysql --port=5900 --protocol=TCP 
(which does work)
since I had specified a TCP port, I anticipated it getting used.
Note that the same thing is present in mysqladmin (you need to specify both port and protocol, at times, to get the port to work).
Thank you!
-Roger

How to repeat:
Install mysql like normal.
Now create a second 'side by side' concurrently running daemon (on a different port)
thus:
create new.cnf:

[mysqld]
port=8900
datadir=/home/roger/mysql/
socket=/home/roger/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
local-infile=1

[mysql.server]
user=roger
basedir=/var/lib
# basedir left the same
local-infile=1

[mysqld_safe]
log-error=/home/roger/mysql/mysqld.log
pid-file=/home/roger/mysql/mysqld.pid

[client]
loose-local-infile=1

now go to that data directory that you want, run 
mysql_install_db --user=roger --ldata=.

mysqld_safe --defaults-file=./my.cnf --user=roger --skip-locking & # maybe nohup this command ?

and it might (should) start it for you...I think....

/usr/bin/mysqladmin --port=8900 --protocol=TCP -u root password 'dbadmin' # works
/usr/bin/mysqladmin --port=8900 -u root password 'dbadmin' #  does not work, when you'd think it would.

Suggested fix:
One way to fix this would be to output a warning if a user specifies a TCP port on the command line and the port ever used ("warning tcp port specification ignored"), and/or to have a verbose mode showing exactly which port IS being used, to make debugging this less painful.
[9 Dec 2010 18:54] Valeriy Kravchuk
It would be nice to have some option (off by default, for backward compatibility) to force TCP instead of socket when --port is used. 

See also: bug #31577