Difference between revisions of "Backup isi database MySQL"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
/usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c | /usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c | ||
+ | /usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c > isidatabase.sql | ||
− | langsung di gz | + | 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 | /usr/bin/mysqldump -u usernamemysql -ppasswordmysql namadb -c | /bin/gzip -9 > isidatabse.sql.gz | ||
+ | [[Database]] akan tersimpan di file | ||
− | Database | + | 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== | ||
+ | |||
+ | * [https://youtu.be/9-kwhBw_Gso YOUTUBE: MySQL backup restore database] | ||
− | |||
Line 18: | Line 42: | ||
* http://ngadimin.org/2009/03/24/backup-mysql-di-ubuntu-atau-di-debian/ | * http://ngadimin.org/2009/03/24/backup-mysql-di-ubuntu-atau-di-debian/ | ||
* http://machine-cycle.blogspot.com/2008/04/backup-mysql-databases.html | * http://machine-cycle.blogspot.com/2008/04/backup-mysql-databases.html | ||
+ | |||
+ | ==mysqldump ke csv== | ||
+ | |||
+ | mysqldump -u your_username -p your_database_name your_table_name --fields-terminated-by=',' --fields-enclosed-by='"' --lines-terminated-by='\n' > outputfile.csv | ||
+ | |||
+ | -u MySQL username. | ||
+ | -p prompts MySQL password. | ||
+ | your_database_name database berisi table | ||
+ | your_table_name table | ||
+ | --fields-terminated-by=',' set field separator ke comma | ||
+ | --fields-enclosed-by='"' set field enclosed ke " | ||
+ | --lines-terminated-by='\n' line terminator | ||
+ | > outputfile.csv redirect output ke CSV file. | ||
+ | |||
==Pranala Menarik== | ==Pranala Menarik== | ||
− | * [[MySQL]] | + | * [[Perintah MySQL]] |
+ | * [[Instalasi MySQL]] | ||
* [[Linux Howto]] | * [[Linux Howto]] | ||
+ | * [[Backup isi database MySQL]] | ||
* [[Reset Password MySQL]] | * [[Reset Password MySQL]] | ||
+ | * [[Mengatasi Masalah Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock']] | ||
+ | * [[Masalah 'mysqld.sock' yang cukup menjengkelkan]] | ||
+ | * [[MySQL: Memperbaiki Corrupt Database]] | ||
+ | * [[MariaDB]] | ||
+ | |||
+ | |||
+ | [[Category: Linux]] | ||
+ | [[Category: Database]] |
Latest revision as of 10:26, 12 January 2024
/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
- http://subair.wordpress.com/2010/03/28/coba-coba-materi-backup-database-mysql-di-ubuntu-server-manual-dan-otomatis/
- http://ngadimin.org/2009/03/24/backup-mysql-di-ubuntu-atau-di-debian/
- http://machine-cycle.blogspot.com/2008/04/backup-mysql-databases.html
mysqldump ke csv
mysqldump -u your_username -p your_database_name your_table_name --fields-terminated-by=',' --fields-enclosed-by='"' --lines-terminated-by='\n' > outputfile.csv
-u MySQL username. -p prompts MySQL password. your_database_name database berisi table your_table_name table --fields-terminated-by=',' set field separator ke comma --fields-enclosed-by='"' set field enclosed ke " --lines-terminated-by='\n' line terminator > outputfile.csv redirect output ke CSV file.