Skip to content

Instantly share code, notes, and snippets.

@rolandovillca
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandovillca/717ef7bcbe7cbe2dbe92 to your computer and use it in GitHub Desktop.
Save rolandovillca/717ef7bcbe7cbe2dbe92 to your computer and use it in GitHub Desktop.
ABOUT MYSQL TIPS
# 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