MySql for Windows,MySql 管理员:计划备份不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8034793/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:24:31  来源:igfitidea点击:

MySql for Windows, MySql Administrator: Scheduled backup not working

mysqlwindowsmysqladministrator

提问by Nehbur

My question is a bit specific, but I hope someone has experience with the issue.

我的问题有点具体,但我希望有人对这个问题有经验。

I'm running a Windows 2008 server with MySql for Windows installed it. It's MySql 5.2 and that package contains "MySql Administrator". There you can make backups of a specific database. When I configure the backups and also say that it needs to be done daily around 3 am in the morning, it doesn't work automatically. It's only when I press "Execute backup now" that I get to save the .SQL file and then the backup itselve works fine. When I ask it to fire automatically nothing is created and not even a log file is being made. I've checked the rights on the selected folder and i've added the user "Everyone" with all rights to rule out any permission issues. No effect.

我正在运行安装了 MySql for Windows 的 Windows 2008 服务器。它是 MySql 5.2,该包包含“MySql Administrator”。您可以在那里备份特定数据库。当我配置备份并说它需要每天凌晨 3 点左右完成时,它不会自动工作。只有当我按下“立即执行备份”时,我才能保存 .SQL 文件,然后备份本身就可以正常工作。当我要求它自动触发时,没有创建任何内容,甚至没有创建日志文件。我检查了所选文件夹的权限,并添加了具有所有权限的用户“Everyone”以排除任何权限问题。没有效果。

I've been Googling for day's and I can't find a solution for this. Does anyone know why my automated backup via the MySQL administrator is not working on MS Windows 2008 and why it isn't even creating a log file?

我一直在谷歌上搜索一天,我找不到解决方案。有谁知道为什么我通过 MySQL 管理员进行的自动备份在 MS Windows 2008 上不起作用,为什么它甚至不创建日志文件?

回答by Serjik

CREATE A USER WITH MINIMUM PERMISSION

以最小权限创建用户

mysql> grant select,lock tables on foo.* to bar@localhost identified by'backup'; 
mysql> flush privileges;

CREATE A BATCH FILE LIKE FOLLOWING AND SCHEDULE IT*This will backup file in specified path with db name + date and time*

创建一个批处理文件,如下所示并安排它*这将使用数据库名称 + 日期和时间备份指定路径中的文件*

@echo off
set mySqlPath=C:\[path to my sql]\mysql5.1.36
set dbUser=bar
set dbPassword=backup
set dbName=MyDB1

set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%

set file=%dbName%.%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%.sql
set path=C:\[path to folder]\mysql_bak

echo Running dump for database %dbName% ^> ^%path%\%file%
"%mySqlPath%\bin\mysqldump.exe" -u %dbUser% -p%dbPassword% --result-file="%path%\%file%" %dbName%
echo Done!

回答by Hitendra Deriya

I got Solution , When you create schedule backup that time MySQL Administrator take information your system username and password. That time give proper system username and password

我得到了解决方案,当您创建计划备份时,MySQL 管理员会获取您的系统用户名和密码信息。那个时候给正确的系统用户名和密码

回答by eli

I tried also using version 1.2.17 with win 7. I faced the same problem.MySQL ADMIN is scheduling the backup via the windows scheduler. I realy don't know why but when i scheduled the backup(when i SAVE the new created project) under a user with an ADMIN account it didn't operate. When i scheduled the backup under a standard ACCOUNT it operated fine. to solve this problem i defined a new standard account in WIN 7 . I am logging to win 7 under my primary account and scheduling the backup under the new account . Now it works fine .

我还尝试在 win 7 中使用 1.2.17 版。我遇到了同样的问题。MySQL ADMIN 正在通过 Windows 调度程序安排备份。我真的不知道为什么,但是当我在具有管理员帐户的用户下安排备份(当我保存新创建的项目时)时,它没有运行。当我在标准帐户下安排备份时,它运行良好。为了解决这个问题,我在 WIN 7 中定义了一个新的标准帐户。我正在登录以在我的主帐户下赢 7 并在新帐户下安排备份。现在它工作正常。

回答by Mário Rodrigues

I guess it might be associated with windows "cron" jobs. Anyway, this do the trick for me:

我想它可能与 windows “cron” 作业有关。无论如何,这对我有用:

http://realm3.com/articles/how_to_schedule_regular_mysql_backups_in_windows

http://realm3.com/articles/how_to_schedule_regular_mysql_backups_in_windows

Of course you have to do everything by hand but is also better. I got this same issue in PostgreSQL because o windows "at" is different from linux "cron". Since than, I started to do my own "cron" jobs.

当然,您必须手动完成所有操作,但也更好。我在 PostgreSQL 中遇到了同样的问题,因为 o windows "at" 与 linux "cron" 不同。从那以后,我开始做自己的“cron”工作。

Also check this: http://kedar.nitty-witty.com/blog/scheduled-backup-mysql-administrator-windows-scheduler-odd

还要检查这个:http: //kedar.nitty-witty.com/blog/scheduled-backup-mysql-administrator-windows-scheduler-odd

Hope it helps! :)

希望能帮助到你!:)

回答by Nehbur

I'll post what are my findings for other people to enjoy.

我会发布我的发现供其他人欣赏。

I didn't get the MySQL Administrator backup function to work automatically, instead I used the suggestion of @mOrSa

我没有让 MySQL 管理员备份功能自动工作,而是使用了@mOrSa 的建议

My findings are these: I've made a batch file using this code:

我的发现是这些:我使用以下代码制作了一个批处理文件:

@echo off
set zy=2011
set zm=1
set zd=17
set zz = ((zy*100)+zm)*100+zd
Set hr=%TIME:~0,2%
Set mn=%TIME:~3,2%
echo Running dump...
C:\Progra~1\MySQL\MYSQLS~1.5\bin\mysqldump -uuser -password --port=3307 --result-file="c:\MySqlBackups\backup_%zz%_%hr%%mn%.sql" meibergen_dbo
echo Done!
echo Deleting old files
forfiles /P "C:\MySqlBackups" /S /M *.sql /D -7 /C "cmd /c del @PATH"
echo Done!

This makes an .SQL file within the chosen folder with the name format being "backup_20110825_14:54.sql". It also deletes all files older than 7 day's in that folder. I have Windows Server 2008, so the file "forfiles.exe" is standard installed within the system32 folder. If you don't have that program, you can download it somewhere for free.

这会在所选文件夹中生成一个名为“backup_20110825_14:54.sql”的 .SQL 文件。它还会删除该文件夹中超过 7 天的所有文件。我有 Windows Server 2008,所以文件“forfiles.exe”是标准安装在 system32 文件夹中。如果您没有该程序,可以在某处免费下载。

After that I've set a scheduled task running this batch file in the Windows Task Scheduler. Make sure you have given the appropriate rights in the schedular. It's executed daily.

之后,我在 Windows 任务计划程序中设置了一个运行此批处理文件的计划任务。确保您已在日程表中授予适当的权限。它每天执行。

回答by Marco Demaio

The simple trick is to create a stored connection(tested on both Win7 and Win2008 with MySQL Administrator 1.2.17 can download it from here, it's among MySQL GUI tools).

简单的技巧是创建一个存储连接(在 Win7 和 Win2008 上测试,MySQL Administrator 1.2.17 可以从这里下载,它在 MySQL GUI 工具中)。

  1. Open MySQL Administrator, then go in menu Tools > Options

  2. In the pop up windows select "Connection" on the left and hit the button "New Connection".

  3. Fill in your connection values: username, password, host... and Save it.

  4. Close MySQL Administartor and re-open it, but this time connect by selecting the new stored connectionyou just created on step (3) from the select list (the select list is the 1st field in the login window)

  5. Now you can create a backup and schedule it, and the schedule will work like a charm.

  1. 打开 MySQL Administrator,然后进入菜单工具 > 选项

  2. 在弹出窗口中选择左侧的“连接”并点击“新建连接”按钮。

  3. 填写您的连接值:用户名、密码、主机...并保存。

  4. 关闭 MySQL Administor 并重新打开它,但这次通过从选择列表中选择您刚刚在步骤 (3) 中创建的新存储连接进行连接(选择列表是登录窗口中的第一个字段)

  5. 现在您可以创建一个备份并安排它,并且该计划将像魅力一样工作。

回答by Daniel

I know it's a old problem but I had the same problem in recent days and searching solutions I couldn't find how to fix my problem but I found some information in my event logs and I remembered I had another connection (obviously, event logs show me that) so I made new connection with the same name which event logs show me and voila, problem fixed.

我知道这是一个老问题,但最近几天我遇到了同样的问题,正在搜索解决方案我找不到如何解决我的问题,但我在我的事件日志中找到了一些信息,我记得我有另一个连接(显然,事件日志显示我那个)所以我用相同的名称建立了新的连接,事件日志显示给我看,问题解决了。