mysqldump command with password code example
Example 1: mysqldump password
add this to .my.cnf file
user can be omitted
[mysqldump]
user=mysqluser
password=secret
The -p option must be excluded from the command in order to use the password in the config file.
Correct:
mysqldump –u my_username my_db > my_db.sql
Wrong:
mysqldump –u my_username -p my_db > my_db.sql
Example 2: mysqldump password in file
[mysqldump]
user=mysqluser
password=secret