What is the SSH command line to back up mysql database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CyberGuy
    Junior Member
    • May 2005
    • 3

    #1

    What is the SSH command line to back up mysql database?

    I want to back up my mysql (.sql) database to my directory so that I can download it (using ftp) to my computer.

    What is the SSH command line to make a full .sql backup of the database?
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    This is what i use.

    1) Make sure you're in the directory you want to save the .sql file down to:

    cd public_html/this_folder

    2) Execute the dump command:

    mysql -u USERNAME -p -D DATABASE_NAME > database_backup.sql

    You'll then be prompted for that usernames password, enter it and the database will be dumped.

    You could also then archive the file to make it smaller using something like the following:

    tar -czvf db_backup.tar.gz database_backup.sql

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

    Comment

    • justoneguy
      Junior Member
      • Jul 2005
      • 17

      #3
      This is what I use...dumps and zips in one command from the shell:

      mysqldump dbname -u username -p | gzip > dbname.gz

      Comment

      • cgcullen
        Member
        • Mar 2004
        • 34

        #4
        How would you later restore this database?

        Comment

        Working...