Reputation: 5812
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
Upvotes: 1
Views: 2054
Reputation: 355079
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
and INSERT 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.
Upvotes: 2