Skip to content

Instantly share code, notes, and snippets.

@rolandovillca
Last active August 29, 2015 14:27

Revisions

  1. rolandovillca revised this gist Aug 19, 2015. No changes.
  2. rolandovillca revised this gist Aug 19, 2015. No changes.
  3. rolandovillca revised this gist Aug 18, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions mysql-commands.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # SEARCH TABLE NAME:
    SHOW TABLES FROM master LIKE '%table_name%';

    # CHECK MYSQL CONF:
    cat /etc/my.cnf

  4. rolandovillca revised this gist Aug 12, 2015. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion mysql-commands.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,15 @@
    # CHECK MYSQL CONF:
    cat /etc/my.cnf

    # MAKE BACKUP DATABASES:
    # 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
  5. rolandovillca revised this gist Aug 12, 2015. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions mysql-commands.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    # CHECK MYSQL CONF:
    cat /etc/my.cnf

    # MAKE BACKUP 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"
  6. rolandovillca renamed this gist Aug 12, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. rolandovillca created this gist Aug 12, 2015.
    6 changes: 6 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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