简体   繁体   English

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

[英]MySql for Windows, MySql Administrator: Scheduled backup not working

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. 我正在运行安装了MySql for Windows的Windows 2008服务器。 It's MySql 5.2 and that package contains "MySql Administrator". 这是MySql 5.2,该软件包包含“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. 当我配置备份并且还说它需要每天凌晨3点左右完成时,它不会自动运行。 It's only when I press "Execute backup now" that I get to save the .SQL file and then the backup itselve works fine. 只有当我按下“立即执行备份”时才能保存.SQL文件然后备份它才能正常工作。 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. 我已经检查了所选文件夹的权限,并且我添加了用户“Everyone”,并拥有排除任何权限问题的所有权利。 No effect. 没有效果。

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上运行,为什么它甚至没有创建日志文件?

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 * 创建一个类似于以下的批处理文件并安排它 * 这将使用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!

I got Solution , When you create schedule backup that time MySQL Administrator take information your system username and password . 我得到了解决方案,当您创建计划备份时, MySQL管理员会获取您的系统用户名和密码信息 That time give proper system username and password 那个时候给出适当的系统用户名和密码

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. 我尝试使用版本1.2.17与win 7.我遇到了同样的问题.MySQL ADMIN通过Windows调度程序安排备份。 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. 我真的不知道为什么,但是当我在具有ADMIN帐户的用户下安排备份(当我保存新创建的项目时)它没有运行。 When i scheduled the backup under a standard ACCOUNT it operated fine. 当我按照标准ACCOUNT安排备份时,它运行正常。 to solve this problem i defined a new standard account in WIN 7 . 为了解决这个问题,我在WIN 7中定义了一个新的标准帐户。 I am logging to win 7 under my primary account and scheduling the backup under the new account . 我正在我的主帐户下登录获胜7并在新帐户下安排备份。 Now it works fine . 现在它工作正常。

I guess it might be associated with windows "cron" jobs. 我想这可能与Windows“cron”工作有关。 Anyway, this do the trick for me: 无论如何,这对我有用:

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". 我在PostgreSQL中遇到了同样的问题,因为o windows“at”与linux“cron”不同。 Since than, I started to do my own "cron" jobs. 从那以后,我开始做自己的“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! 希望能帮助到你! :) :)

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 Administrator备份功能自动工作,而是使用了@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". 这使得所选文件夹中的.SQL文件的名称格式为“backup_20110825_14:54.sql”。 It also deletes all files older than 7 day's in that folder. 它还会删除该文件夹中超过7天的所有文件。 I have Windows Server 2008, so the file "forfiles.exe" is standard installed within the system32 folder. 我有Windows Server 2008,因此文件“forfiles.exe”是system32文件夹中的标准安装。 If you don't have that program, you can download it somewhere for free. 如果您没有该程序,可以免费下载到某个地方。

After that I've set a scheduled task running this batch file in the Windows Task Scheduler. 之后,我在Windows任务计划程序中设置了运行此批处理文件的计划任务。 Make sure you have given the appropriate rights in the schedular. 确保您已在计划中授予适当的权利。 It's executed daily. 它每天执行。

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 打开MySQL Administrator,然后进入菜单工具>选项

  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 connection you just created on step (3) from the select list (the select list is the 1st field in the login window) 关闭MySQL Administartor并重新打开它, 但这次通过从选择列表中选择刚刚在步骤(3)创建的新存储连接进行连接 (选择列表是登录窗口中的第一个字段)

  5. Now you can create a backup and schedule it, and the schedule will work like a charm. 现在,您可以创建备份并对其进行计划,并且计划将像魅力一样工作。

我知道这是一个老问题,但我最近几天遇到了同样的问题并且搜索解决方案我找不到如何解决我的问题,但我在事件日志中发现了一些信息,我记得我有另一个连接(显然,事件日志显示我,所以我用相同的名字建立了新的连接,事件日志显示我和瞧,问题已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM