Hi everybody

I have been using mysqldump utility to dump the contents of database to a file.

Everything is ok
but i want to eliminate the "USE `db_name`;" statement that appears in mysqldump.

Is it possible to do that.
Please help:sweat:

7 Years
Discussion Span
Last Post by nccsbim071


It might depend on the version but normally if you dump a specific database it does not include the USE statement.

mysqldump my_cool_db -u root -p > mysqldumpfile.sql

Or you could set up a script that will create individual dumps for databases who's names are listed in a file. For example if your file that contains the list of databases you want to create mysql dumps for is called:
And you want the files to be created in /var/backups/databases. the script could look like:

for x IN `cat /home/me/mydb.list `
mysqldump -u <USER> -p<PASSWORD> $x > /var/backups/database/$x

1. The DO should be lower case do but it keeps showing as DO when I review my post.
2. You will need to use a real user name with access to the database in place of <USER> and <PASSWORD> and there is a space between -u and the user name but not between -p and the password.

Hope this makes sense and helps.


I am using MySql version 5.0.51b.
and i am successfully able to dump the file but with "use db_name" statement.

Anyway thanks for reply

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.