To use a specific port with the
mysqldump command, you can provide the
-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.
-P remember to use an uppercase
P, because the lowercase option
-p refers to the password.
Here’s the general syntax of using
mysqldump with a specific port:
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.