Malam Pemirsa setia :D
Good night...!
Here Coding to BackUp and Restore your Database with Delphi
for example :
Database : Bengkel ( colored Red, according to your own database - tergantung anda )
Password : 1234 ( colored Red, same, it totally based on your own password - tergantung anda )
Folder MySQL : C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\
(folder MySQL it depends on your directory - tergantung tempat anda install mysql)
add component SaveDialog and OpenDialog on your form
BackUp
SaveDialog1.Execute;
if SaveDIalog1.FileName<>'' then
begin
ShellExecute(self.Handle, PCHAR('open'),
PCHAR('C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqldump.exe'),
PCHAR('-uroot -p1234 -hlocalhost -R -r "'+ SaveDialog1.FileName+'.sql" bengkel'),
PCHAR('C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin'),SW_SHOW);
MessageDlg('Data Berhasil di Backup !!', mtInformation, [mbOK], 0);
end
else
MessageDlg('GAGAL. Harap Pilih Lokasi!!', mtInformation, [mbOK], 0);
Restore
OpenDialog1.Execute;
if OpenDialog1.FileName<>'' then
begin
ShellExecute(self.Handle,pchar('open'),
PCHAR('C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysql.exe'),
PCHAR('-uroot -p1234 -hlocalhost -e "drop database if exists bengkel; '+
'create database bengkel; use bengkel;\. '+OpenDialog1.FileName+'"'),nil,SW_HIDE);
MessageDlg('Data Berhasil di Restore !!', mtInformation, [mbOK], 0);
end
else
MessageDlg('GAGAL. Harap Pilih Lokasi !!!', mtInformation, [mbOK], 0);
end;
OK easy right?
thanks 4 ur attention and see the next Update at giavano.blogspot.com
Thank you
save dialog sama open dialognya itu komponen bawaan delphi atau gimana gan?
BalasHapusiya gan, itu komponen bawaan
BalasHapusdrag n drop aja kalo bingung create pake coding mah
cari aja komponen save dialog dan open dialog.
gan kok databasenya gak muncul y gan ketika di backup?
BalasHapussimpennya dimana gan?
Hapuskan disana harus ada saveDialog. jadi databasenya akan ter backup di tempat kita nge-save...
kalo restore agak lama
kalo backup 2 database ato lebih gmn ? trims
BalasHapussaran saya pakai MySQL Administrator.
Hapusbackup langsung dari server, jauh lebih cepat. :)
kalo memang harus pakai dari client, coding diatas diubah untuk bagian nama databasenya (jadikan parameter) sehingga pada saat mem-backup user dapat memilih database yang diinginkan.
kalau pake acces bisa gak gan?
BalasHapus