phpMyAdmin is fine for smaller databases, but large imports can time out. Importing over SSH is faster and more reliable.
- Create the database and user in cPanel (see How to create a MySQL database).
- Upload your .sql file to your home directory using File Manager or SFTP. Compressed files (.sql.gz) save time.
- Connect via SSH (see How to connect via SSH).
- Run:
mysql -u cpuser_dbuser -p cpuser_dbname < backup.sql
For a compressed file:
gunzip < backup.sql.gz | mysql -u cpuser_dbuser -p cpuser_dbname
- Enter the database user's password when asked. The terminal shows nothing until the import finishes.
If it fails
- If the dump contains
CREATE DATABASEorUSElines near the top naming a different database, remove or comment them out. - "Access denied" means the user isn't assigned to the database or the password is wrong.
- Delete the .sql file once done.