MariaDB’s default port is 3306. However, you can modify this port following the instructions below:
1. Firstly, open the `my.cnf` file. This is usually located in `/etc/mysql/my.cnf`, `/etc/my.cnf`, or `/etc/mysql/mariadb.conf.d/50-server.cnf` \`\`\` sudo nano /etc/mysql/my.cnf \`\`\` If you can’t find it in these locations, run the following MySQL command to find it: \`\`\` mysql —help | grep “Default options” -A 1 \`\`\`
1. Add or change the port number under the `[mysqld]` or `[mariadb]` section depending on the version in use: \`\`\` [mysqld] port = Your_Desired_Port\_Number \`\`\`
1. Save and close the file.
1. Restart the MariaDB service for the changes to take effect. \`\`\` sudo systemctl restart mariadb.service \`\`\`
Alternatively, if you’re using another service manager, use the relevant command, like: \`\`\` sudo service mariadb restart \`\`\` or \`\`\` sudo /etc/init.d/mysql restart \`\`\`1. To verify if the port has been changed correctly, run the following command:
\`\`\`
sudo netstat -plntu | grep mysql
\`\`\`
The `Your_Desired_Port_Number` should be replaced with the port number you want the MariaDB server to listen on.
Remember that when you change the default MariaDB port you also need to update your applications to connect to the new port as well.