Mysql通过存储过程恢复数据库
我想通过存储过程恢复mysql数据库?是否可以?
或者我可以复制 dbfile 并重命名该文件夹吗?
如果有人需要更多信息来回答这个问题,请告诉我。
提前致谢。
问候, 玛纳西
I want to restore mysql database through stored procedure? Is it possible?
Or can I copy dbfile and rename that folder?
Please let me know if anyone needs more information to answer this question.
Thanks in advance.
Regards,
Manasi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于“恢复”的含义:
使用存储过程恢复数据库的唯一方法是通过 SQL 访问备份,因此数据必须包含在可通过存储过程访问的某些表中。在这种情况下,只需编写 SQL,使用少量
CREATE TABLE
和INSERT INTO...SELECT 将数据从一个数据库的表复制到另一个数据库的表即可。
语句。无法在存储过程中使用 LOAD DATA INFILE ,因此您无法提取原始数据转储,并且无法(至少在 MySQL 中)执行驻留的脚本在磁盘上,因此 mysqldump 的转储不起作用。
您当然不能从存储过程中移动文件和文件夹;当 MySQL 运行时你不应该这样做。
It depends what you mean by "restore:"
The only way you could restore a database using a stored procedure is if the backup is accessible via SQL, so the data would have to be contained in some tables accessible from the stored procedure. In that case, it's a simple matter of writing the SQL to copy the data from the tables of one database to the tables of another using a handful of
CREATE TABLE
andINSERT INTO...SELECT
statements.It isn't possible to use
LOAD DATA INFILE
in a stored procedure, so you can't pull in a raw data dump, and there's no way (in MySQL, at least) to execute a script residing on disk, so a dump from mysqldump wouldn't work.You certainly can't move files and folders around from a stored procedure; you should never do that while MySQL is running.