What is the optimal way to store port numbers in a MySQL database?

int, mysql

Solution

Port number is an unsinged 16-bit integer. That means the highest value can be 65535. So you can use SMALLINT.

Problem

If I want to store a port number in MySQL, what is the most efficient way (minimizing wasted space) to do so? Is it `INT(5)` or `INT(3)`? I'm looking here and I think the answer is `INT(3)` (or perhaps `MEDIUMINT`).

Original source