Reputation: 1
I am trying to make some normal (understand restorable) backup of mysql backup. My problem is, that I only need to back up a single table, which was last created, or edited. Is it possible to set mysqldump to do that? Mysql can find the last inserted table, but how can I include it in mysql dump command? I need to do that without locking the table, and the DB has partitioning enabled.... Thanks for help...
Upvotes: 0
Views: 1811
Reputation: 19
For dumping a single table use the below command.
Open cmd prompt and type the path of mysql like c:\program files\mysql\bin
.
Now type the command:
mysqldump -u username -p password databasename table name > C:\backup\filename.sql
Here username
- your mysql username
password
- your mysql password
databasename
- your database name
table name
- your table name
C:\backup\filename.sql
- path where the file should save and the filename.
If you want to add the backup table to any other database you can do it by following steps:
type the below command
mysql -u username -p password database name < C:\backup\filename.sql
Upvotes: 0
Reputation: 47311
You can use this SQL to get the last inserted / updated table :-
select table_schema, table_name
from information_schema.tables
where table_schema not in ("mysql", "information_schema", "performance_schema")
order by greatest(create_time, update_time) desc limit 1;
Once you have the results from this query, you can cooperate it into any other language (for example bash) to produce the exact table dump).
Upvotes: 0