How to change MySQL default port

Last updated on 25/01/2019

By default, the port used by MySQL is 3306.

You might want to change it for different reasons, ie: You're running Docker containers of MariaDB or MySQL requiring the same port to be available.

To do that, you have to search for your MySQL conf file and edit the port.

On Ubuntu, normally you'll find it on: /etc/mysql/mysql.conf.d/mysqld.cnf

Search for:

port = 3306

and change it to whatever you want (3307 should be safe so it doesn't interfere with any other service)