MySQL 5.6 - 如何在没有密码提示的情况下使用 mysqldump 在 Windows 上创建备份
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19248567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL 5.6 - how to create a backup on Windows using mysqldump without a password prompt
提问by Highly Sceptical
I am a MySQL novice but need to schedule a task to automatically back up my databases.
我是 MySQL 新手,但需要安排一个任务来自动备份我的数据库。
I have managed to create a backup manually using the following command :-
我已设法使用以下命令手动创建备份:-
mysqldump -u root -p --all-databases > "a:\mysql\all_databases.sql"
But I cannot work out how to run the command without having to manually enter my password. I have tried:--
但是我无法弄清楚如何在无需手动输入密码的情况下运行该命令。我试过了: -
mysqldump -u root -p'*my password*' --all-databases > "a:\mysql\all_databases.sql"
Which appears to execute, but the resultant file is only 1kB in size. Whereas the first command generates a file that is 2661kB.
似乎可以执行,但生成的文件大小仅为 1kB。而第一个命令生成一个 2661kB 的文件。
Can anyone help me?
谁能帮我?
回答by ethanh
Try the following command, replace "your_password" with the root password:
尝试以下命令,将“your_password”替换为 root 密码:
mysqldump --user=root --password=your_password --all-databases >"a:\mysql\all_databases.sql"
回答by user1797147
Even it's a old thread :) For FULL backups including users, access rights (like my case) performance_schema, functions, routines & triggers, you don't need mysqldump at all.
即使它是一个旧线程 :) 对于包括用户、访问权限(如我的情况)performance_schema、函数、例程和触发器的完整备份,您根本不需要 mysqldump。
Download & install 7zip on your machine. Stop your mysql server. Open command prompt and use this:
在您的机器上下载并安装 7zip。停止你的 mysql 服务器。打开命令提示符并使用:
"C:\Program Files-Zipz.exe" a -t7z -mx9 -mhe -p<my_secure_password> "W:\backup_all_mysql_databases.7z" "W:\wamp\bin\mysql\mysql5.6.17\data"
For uncompressed 186MB of /data folder you will get 170KB of 7z archive. You can create a BAT file for appending current datetime to file.
对于未压缩的 186MB /data 文件夹,您将获得 170KB 的 7z 存档。您可以创建一个 BAT 文件以将当前日期时间附加到文件中。
Restoring means to un-compress, delete old /data folder from mysql and replace with the one from backup.
恢复意味着解压缩,从mysql中删除旧的/data文件夹并替换为备份中的文件夹。
There is a minor drawback... if you forget the root password (like me) you'll have a unusable restore of databases too.
有一个小缺点......如果你忘记了 root 密码(像我一样),你也会有一个无法使用的数据库恢复。
That's all.
就这样。