Last active
August 29, 2015 14:27
-
-
Save rolandovillca/717ef7bcbe7cbe2dbe92 to your computer and use it in GitHub Desktop.
ABOUT MYSQL TIPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SEARCH TABLE NAME: | |
SHOW TABLES FROM master LIKE '%table_name%'; | |
# CHECK MYSQL CONF: | |
cat /etc/my.cnf | |
# BACKUP SINGLE DATABASE: | |
mysqldump -u username -p database_to_backup > backup_name.sql | |
# RESTORE SINGLE DATABASE: | |
# To restore a database dump created with mysqldump, you simply have to redirect the file into MySQL again. | |
# Create a blank database, then redirect the dump file. | |
mysql -u username -p database_name < backup_name.sql | |
# BACKUP MULTIPLE DATABASES: | |
sudo mysqldump -uroot --all-databases > my_directory/all-databases.sql | |
mysqldump -uroot -ppassword --all-databases | gzip > /home/backupdir/db.sql.gz | |
database=`mysql --user=<enter username> --password=<enter password> -e "SHOW DATABASES"` | |
for db in $database; do | |
echo "$db" | |
mysqldump --user="<enter username>" --password="<enter password>" --databases "$db" > <path_to_store_your_database>/"$db".sql | |
gzip "$db" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment