[英]MySQL 5.6 - how to create a backup on Windows using mysqldump without a password prompt
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. 这似乎执行,但结果文件的大小只有1kB。 Whereas the first command generates a file that is 2661kB.
而第一个命令生成一个2661kB的文件。
Can anyone help me? 谁能帮我?
尝试以下命令,将“your_password”替换为root密码:
mysqldump --user=root --password=your_password --all-databases >"a:\mysql\all_databases.sql"
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. 在您的计算机上下载并安装7zip。 Stop your mysql server.
停止你的mysql服务器。 Open command prompt and use this:
打开命令提示符并使用:
"C:\Program Files\7-Zip\7z.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. 对于未压缩的186MB / data文件夹,您将获得170KB的7z存档。 You can create a BAT file for appending current datetime to file.
您可以创建BAT文件以将当前日期时间附加到文件。
Restoring means to un-compress, delete old /data folder from mysql and replace with the one from backup. 恢复意味着解压缩,从mysql中删除old / 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. 就这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.