Restoring a MySQL database via SSH is a quick and reliable method, especially when managing VPS or dedicated servers without a control panel. Whether you're recovering from a crash or migrating data, this method ensures efficient restoration directly from the terminal.

Step 1: Log in to the VPS with the root user

# ssh root@VPS_IP_address

Step 2: Run the restore command

# mysql -u [username] -p [database_name] < [dump_file.sql]
  • Replace database_name with the name of the empty database into which you want to restore data.
  • Replace dump_file.sql with your actual backup file name.

Step 3: Enter login credentials

If prompted, provide the MySQL username and password to proceed with the restore.

Conclusion:

Using SSH to restore a MySQL database is efficient and precise, perfect for developers and sysadmins who prefer terminal-based control. Just ensure your target database exists and is empty, and you'll have your site or app back online in no time.

Was this answer helpful? 0 Users Found This Useful (0 Votes)