User Tools

Site Tools


random_useful_mysql_commands

Random useful MySQL Commands

   setsid mysql -s -r -u admin -p`cat /etc/psa/.psa.shadow` -e 'show databases' | while read db; do mysqldump -u admin -p`cat /etc/psa/.psa.shadow` $db -r /var/backup/${db}.sql; [[ $? -eq 0 ]] && gzip /var/backup/${db}.sql; done

Setsid is used to put a process in the background when run from a terminal.

The command above also dumps all databases on a server to separate files.

   mysqldump -u root -p --all-databases > all_dbs.sql

The command above dumps all databases to a single file.

The following command will dump a single database into a .sql file:

   mysqldump --databases test > dump.sql
random_useful_mysql_commands.txt · Last modified: 2017/03/22 23:19 (external edit)