Why is the mysql client utility not using the port I specify?

Solution 1:

If you are running the mysql client on the same host that the server is running, it is probably making a socket connection, and not using the port at all. Try adding --protocol=TCP to your command

mysql -uroot --protocol=TCP --port=1234

Solution 2:

If you use TCP/IP you should specify the host IP. If the host is localhost, you must use 127.0.0.1 instead.

In other words

mysql -uroot -h127.0.0.1 -P1234 -p (if the root has a password)

mysql -uroot -h127.0.0.1 -P1234 (if the root does not has a password)

Once logged in, run this query to make sure:

SHOW VARIABLES LIKE 'port';