gpt4 book ai didi

mysql - 如何使用mysql事件将表备份到本地磁盘

转载 作者:行者123 更新时间:2023-11-29 21:56:03 24 4
gpt4 key购买 nike

我正在尝试使用下面的 mysql 命令将一个数据库表作为 .sql 文件备份到本地路径,

create event backupIn_home_Directory_sqlfile on every 1 day
starts '2015-10-14 16:10:00'
do
select * into outfile 'C:\Users\username\Desktop/backupcehcking.sql' from testingDB.table_test;

但我收到以下错误:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual    that
corresponds to your MySQL server version for the right syntax to use near 'every
1 day starts '2015-10-15 13:10:00' do select * into outfile 'C:\Users\user' at
line 1

我做错了什么?

根据答案,我更改了命令,

mysql> alter event backupIn_home_Directory_sqlfile do select * into outfile 'C:\
Users\RAGHU_ZANCT\Documents\DBbackup_Checking\backupcehcking.sql' from testing.m
anitest;
Query OK, 0 rows affected (0.00 sec)

mysql> alter event backupIn_home_Directory_sqlfile on schedule every 1 day start
s '2015-10-15 15:28:00';

尽管我在该特定文件夹中找不到 backupcehcking.sql 文件。为什么?

最佳答案

我想你忘记了SCHEDULE

使用这个:

create event backupIn_home_Directory_sqlfile on schedule every 1 day

示例语法:

CREATE EVENT event_name
ON SCHEDULE
EVERY 1 DAY
COMMENT 'Optinal comment goes here'
DO
YOUR QUERY;

关于mysql - 如何使用mysql事件将表备份到本地磁盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33141828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com