Beranda > Catatan Kecil > BACKUP, RESTORE dan CLONING database MySQL

BACKUP, RESTORE dan CLONING database MySQL

BACKUP:

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysqldump -h[host] -u[username] -p[password] [nama_database]>[tujuan_backup]), nil, SW_HIDE);

RESTORE:

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysql -u[username] -p[password] [database]<[file_backup]’), nil, SW_HIDE);

 

CLONING:

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysqldump -u[user] –password=[password] [databaselama] | mysql -u[user] –password=[password] -hlocalhost [databasebaru]’), nil, SW_HIDE);

 

CONTOH :

 

uses shellAPI;

 

{Backup}

 

procedure TForm1.btn_backup(Sender: TObject);

begin

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysqldump -hlocalhost -uroot -parradys uji_coba>c:\coba.sql’), nil, SW_HIDE);

end;

 

procedure TForm1.btn_restore(Sender: TObject);

begin

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysql -uroot -parradys uji_coba<c:\coba.sql’), nil, SW_HIDE);

begin

 

procedure TForm1.btn_cloning(Sender: TObject);

begin

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’), PChar(‘/c mysqldump -uroot –password=arradys ujicoba | mysql -uroot –password=arradys -hlocalhost cobabaru’), nil, SW_HIDE);

begin

 

Nambahin Dikit

 

RESTORE

SetEnvironmentVariable(PChar(‘Path’),PChar(‘C:\xampplite\mysql\bin’));

ShellExecute(Handle, ‘open’, PChar(‘cmd.exe’),

pchar(‘/c mysql -u root -h localhost -e “drop database if exists databaseku; ‘+’create database databaseku;use databaseku;\. ‘+edrestore.Text+'”‘),nil,sw_hide);

 

//kalo pake password tinggal kasi -p passworku

 

😀 Restorenya bisa create database mapupun table walopun ga ada (belum di buat) ampuh tuh gan, ane gabung2in coding2 dari master2 di sini tinggal sesuaiin aja directory  nya:)

—- KPPDI —–

Iklan
Kategori:Catatan Kecil
  1. April 8, 2016 pukul 8:51 pm

    sapa kat linux takde support? kau yg tak pandai explore mcmana nak tau. Click https://twitter.com/moooker1

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: