问题描述
如何备份MySQL用户及其特权?
类似mysqldump的东西?
我正在寻找:
mysqldump -d -u root -p MyTable > Schema.sql
推荐答案
mysql -BNe "select concat('\'',user,'\'@\'',host,'\'') from mysql.user where user != 'root'" | \ while read uh; do mysql -BNe "show grants for $uh" | sed 's/$/;/; s/\\\\/\\/g'; done > grants.sql
其他推荐答案
您可以使用
备份MySQL数据库mysqldump -u root -p mysql > mysql.sql
和通过执行
来还原mySQL数据库mysql -uroot -p mysql < mysql.sql
不要忘记
FLUSH PRIVILEGES
恢复转储后.
希望它有帮助...
其他推荐答案
到目前为止,我在MySQL上的经验,我没有看到备份用户及其特权通过命令行.
但是我可以通过备份mySQL
来备份这些关键数据mysqldump -u root -p mysql > mysql.sql
问题描述
How do I backup MySQL users and their privileges?
Anything like mysqldump?
I am looking for something like:
mysqldump -d -u root -p MyTable > Schema.sql
推荐答案
mysql -BNe "select concat('\'',user,'\'@\'',host,'\'') from mysql.user where user != 'root'" | \ while read uh; do mysql -BNe "show grants for $uh" | sed 's/$/;/; s/\\\\/\\/g'; done > grants.sql
其他推荐答案
You can backup mysql database using
mysqldump -u root -p mysql > mysql.sql
and restore mysql database by executing
mysql -uroot -p mysql < mysql.sql
Dont forget to
FLUSH PRIVILEGES
after restoring dump.
Hope it helps...
其他推荐答案
So far my experience with MySQL i didn't see anything to backup user and their privileges through a command line.
But i can backup those critical data by backing up mysql
mysqldump -u root -p mysql > mysql.sql