mysqldump –-user [user name] –-password=[password] [database name] > [dump file]
Let's take a look at each of the arguments that can be passed to the mysqldump utility, as shown above:
Let's take a look at each of the arguments that can be passed to the mysqldump utility, as shown above:
--user [user name]: The --user flag followed by a valid MySQL username tells MySQL the username of the account that we want to use to perform the database dump.
--password=[password]: The password for the user account mentioned above.
[database name]: The name of the database that we would like the mysqldump utility to backup.
> [dump file]: If you're familiar with DOS and batch files, then you will know that the ">" symbol specifies that we are directing output to a stream, port, or file. For the mysqldump utility, we prepend a ">" to the filename we would like our database to be backed up to. If no path is specified for the file, then it will be created in the current directory.
Example:
mysqldump --user user_dbuser --password=password user_dbname > sql.dump
In the example above, we're specifying that MySQL should check the grants for the user account of the "admin" user with a password of "password". I'm running MySQL on Windows 2000, and these are the default credentials for the admin user account. I have chosen to backup the database named "mydatabase" into the file sql.dump.
mysqldump --user user_dbuser --password=password user_dbname > sql.dump
In the example above, we're specifying that MySQL should check the grants for the user account of the "admin" user with a password of "password". I'm running MySQL on Windows 2000, and these are the default credentials for the admin user account. I have chosen to backup the database named "mydatabase" into the file sql.dump.