# mysqldump: how to use a specific port
The default port of MySQL and MariaDB is 3306. Because of that,
mysqldump also uses 3306 as default port.
In case you want to use a different port when running
mysqldump, all you need to do is include the
--port flag (or
-P) in the command.
# Using the --port flag mysqldump my_database --port=12345 > my_backup.sql # Using the -P flag mysqldump my_database -P 12345 > my_backup.sql
After running the command from the example above, mysqldump will try to connect using the port 12345 instead of the default one.
In case you want to use
-P instead of
--port, remember to use a capital P because
-p means password, not port.
In case you want to backup a remote database, here we have a full article about that.