views:

21

answers:

2

Alright,

Let me preface this with the fact that I'm assuming I am lacking a fundamental understanding of mysql. I'm attempting to assemble all the options that I need for mysqldump to create everything used by my applications database into a single script. This includes the database itself and all the database users/passwords/privileges.

I've got it all figured out with the exception of the user piece... here's what I'm currently using:

mysqldump -h host -u root -p --add-drop-database --routines -B database_name > backup.sql

So, what am I missing?

Thanks in advance!

BB

A: 

The database users/passwords/privileges are kept in the mysql database, and won't get dumped with your dump command. You'll have to it to the list of DBs to dump:

mysqldump ... --routines --databases database_name mysql > backup.sql

or just dump everything:

mysqldump ... --routines --all-databases > backup.sql
Marc B
Perfect - that's what I just found out. I'd suggest that we just warn people that dumping/restoring the mysql db vs using the script I linked to could have some unintended effects esp. if the two servers aren't mirror images of each other (they don't have the same db's on them).
Bobby B
A: 

So, I had a fundamental misunderstanding. Users are not specific to a database, but are rather created at the server level.

You can view all existing users with the following query:

SELECT * FROM mysql.user;

Knowing this, it's pretty obvious that mysqldump shouldn't do anything with users. However, if you need an answer to exporting/importing users and perms I suggest you check the following article - it helped me out.

http://pento.net/2009/03/12/backing-up-permissions-for-individual-databases/

My apologies for the noise on the board, but I figured I'd leave the post incase anyone else has the same misunderstanding.

Bobby B
Nope, this was just the thing to do. Additionally, if this post was what ACTUALLY let you solve it, then you should mark THIS ANSWER as "the answer" instead of the other one. Just thought I would share.
drachenstern