I was testing a connection issue and tested port 3307 as specified in my JDBC URL. It worked, so I assumed it was on that port. Then I saw the default port was 3306 and tried random ports, and it still worked. I expected it to fail. Why is it ignoring the port on the command line?
$ mysql -u root --port 999 -h localhost gb
MariaDB [gb]> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
$ mysql --version
mysql Ver 15.1 Distrib 10.1.30-MariaDB, for CYGWIN (i686) using EditLine wrapper
I also tried -P 999
and it worked.
$ mysql -u root --port 999 -h 127.0.0.1 gb
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")
– Earsplitting