How to export tables and import MySQL tables via CLI/SSH

    October 17, 2019

    This method requires SSH access. Nexcess clients on physical (non-cloud) servers must first enable SSH access and adjust their firewall settings in SiteWorx; Cloud accounts have SSH enabled by default.

    1. SSH into the server and enter the following command, but remove the brackets and replace the placeholder text within those brackets:
      mysqldump -u [username] -p [database_name] > [dumpfilename.sql]
    2. Enter your password when prompted.

    3. To accelerate the upcoming transfer to the new server, execute the following command, but remove the brackets and replace the placeholder text within those brackets:
      tar zcf [dumpfilename].tar.gz [dumpfilename].sql
    4. Transfer the compressed file to the new server using FTP.

    5. On the new server, decompress the file:
      tar zxf [dumpfilename].tar.gz
    6. Launch the import process:
      mysql -u [username] -p [database_name] < [dumpfilename.sql]
    7. Enter your password when prompted to begin the import.

    8. When you see the ready cursor, the import has finished.

    Other resources

    For the complete MySQL documentation, refer to the MySQL development website.


    For 24-hour assistance any day of the year, contact our support team by email or through your Client Portal.

    Was this article helpful?

    Send feedback

    Can’t find what you’re looking for?

    Our award-winning customer care team is here for you.

    Contact Support