Skip to content

Instantly share code, notes, and snippets.

@masasdani
Created March 9, 2012 06:33
Show Gist options
  • Save masasdani/2005349 to your computer and use it in GitHub Desktop.
Save masasdani/2005349 to your computer and use it in GitHub Desktop.
mysql backup and reset
#mysql-backup
mysqldump -h localhost –u root –p myrootpassword db_name > db_test.sql
#for multiple database
mysqldump -h localhost –u root –p myrootpassword db_name1 db_name2 > db_test.sql
#for all table
mysqldump -h localhost –u root –p myrootpassword -all-databases > db_test.sql
#for specifiec table
mysqldump --user root --password=myrootpassword db_test customers \ > db_test_customers.sql
#restoring
mysql --user root --password=myrootpassword new_db < db_test.sql
#reset password
sudo su
/etc/init.d/mysql stop
mysqld_safe --skip-grant-table --user=root
mysql -u root -p
UPDATE mysql.user set Password=PASSWORD('passwordbaru') WHERE user='root';
flush privileges;
exit;
/etc/init.d/mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment