Importing MySQL Databases via SSH
Print this Article
Last Updated:
May 24, 2012 11:38 AM
Servers without a control panel (such as cPanel, Plesk, or Simple Control Panel) do not have phpMyAdmin installed. To manage databases without a control panel, you need to use the SSH command line to import .SQL backup files.
To Import MySQL Databases via SSH
- Open the .SQL file in a text editor to ensure it is formatted to use the correct database. There should be a use database command at the top, and it should reference the database that is receiving the imported data. If this command is not included, you can add or use it once you log in to MySQL.
- Log in to SSH as the root user. If you do not know how to do this, see How do I access MySQL using SSH?
- To log in to MySQL, type mysql -u username -p Enter password: password (where username and password are your database user name and password).
- If you did not include the use database command in the .SQL file, select the target database of the import. Do this by typing use database_name; and then press Enter.
- Type SOURCE /path/to/sql/file.sql, and then press Enter.
- Monitor the running import log to check for errors.
- To confirm the data was imported correctly, type show tables; and then press Enter.
- Type select * from table; and then press Enter. Your imported MySQL database tables display.