Difference between revisions of "Backup isi database MySQL"

From OnnoWiki
Jump to navigation Jump to search
Line 30: Line 30:
  
 
  mysql -u root -p123456 dvwa < backup-dvwa.sql
 
  mysql -u root -p123456 dvwa < backup-dvwa.sql
 +
 +
==Youtube==
 +
 +
* [https://youtu.be/9-kwhBw_Gso YOUTUBE: MySQL backup restore database]
 +
 +
  
 
==Referensi==
 
==Referensi==

Revision as of 06:08, 28 May 2020

Dump isi database MySQL

/usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c
/usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c > isidatabase.sql

jika kita menginginkan agar file yang di hasilkan langsung di gz, kita dapat menggunakan perintah

/usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c | /bin/gzip -9 > isidatabse.sql.gz

Database akan tersimpan di file

isidatabase.sql.gz

Restore Database

mysqladmin --user=usernamemysql --password=passwordmysql --force drop namedb
mysqladmin --user=usernamemysql --password=passwordmysql create namedb

contoh

mysqladmin --user=root --password=123456 --force drop dvwa
mysqladmin --user=root --password=123456 create dvwa

restore database

gunzip isidatabase.sql.gz
mysql -u usernamemysql -ppasswordmysql namedb < isidatabase.sql

contoh

mysql -u root -p123456 dvwa < backup-dvwa.sql

Youtube


Referensi

Pranala Menarik