The default port that MySQL database server is running under Linux and Unix is 3306/TCP. In order to change the default MySQL/MariaDB database port in Linux, open MySQL server configuration file for editing by issuing the below command.
Search for the line stat starts with [mysqld] and place the following port directive under [mysqld] statement, as shown in the below file excerpts. Replace the port variable accordingly
After you’ve added the new MySQL/MariaDB port, save and close the configuration file.
If you use SELinux, you should install the following package under CentOS 7 in order to apply the required SELinux rules to allow the database to bind on the new port.
Next, add the below SELinux rule to bind MySQL socket on the new port and restart the database daemon to apply changes, by issuing the following commands. Again, replace MySQL port variable to match your own port number.
In order to verify if the port configuration for MySQL/MariaDB database server has been successfully applied, issue netstat or ss command and filter the results via grep command in order to easily identify the new MySQL port.