Importing and exporting a MySQL database via SSH

How to dump and restore databases from the command line.

phpMyAdmin is fine for small databases, but push it too hard and things fall apart — the browser times out, large dumps fail to upload, and you're left staring at an error page. For anything substantial, it's far better to handle imports and exports directly over SSH. It's faster, more reliable, and there are no file size limits to worry about.

Import

mysql -uUSER -pPASSWORD DBNAME < /path/to/DUMPFILE.sql

Note: there's no space between the -u and -p flags and their values.

Where:

  • USER — your database username (e.g. u111111_dbuser)
  • PASSWORD — your database password
  • DBNAME — the name of the database you're importing into (e.g. u111111_database)
  • /path/to/DUMPFILE.sql — the full path to your dump file

Our products and services

Web HostingReliable hosting services for websites of any scale.
Order
VPSFlexible cloud infrastructure with full root access.
Order
Dedicated ServersBare metal servers for maximum performance.
Order

Export

mysqldump -uUSER -pPASSWORD DBNAME > /path/to/DUMPFILE.sql

Same rule applies: no space between -u, -p and their values.

Where:

  • USER — your database username (e.g. u111111_dbuser)
  • PASSWORD — your database password
  • DBNAME — the name of the database you're exporting (e.g. u111111_database)
  • /path/to/ — the directory where the dump file will be saved
  • DUMPFILE.sql — the filename for the exported dump

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us