wine barrels in a wine cellar

mysqldump: how to use a specific port

Written by

in

The mysqldump client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data.

By default, the mysqldump command uses the port 3306 to connect to the database. To use a different port, you can provide the --port (or -P) option followed by the port number you want to use. The --port option specifies the TCP/IP port number to use when connecting to the MySQL server.

Note: when using -P remember to use an uppercase P, because the lowercase -p refers to the password option.

Here’s the general syntax of using mysqldump with a specific port:

Bash
mysqldump --port=PORT_NUMBER -u USERNAME -p DATABASE_NAME > dump.sql

Replace the following placeholders:

  • PORT_NUMBER: The specific port number you want to use (e.g., 3306).
  • USERNAME: Your MySQL username.
  • DATABASE_NAME: The name of the database you want to dump.
  • dump.sql: The name of the file where you want to save the database dump.

After executing this command, you’ll be prompted to enter your MySQL password. Once you provide the correct password, the mysqldump command will connect to the MySQL server using the specified port and create a dump of the specified database.

A full list of options to be used with mysqldump is listed on the MySQL documentation.

Foto von André Carvalho auf Unsplash


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *