Connect to the server over Secure Shell (SSH), move to the folder holding the file with cd, then run mysql -u username -p database < mysql_file.sql. The -p flag makes the command prompt for the database user's password. The terminal shows nothing while you type that password. The command line avoids phpMyAdmin's upload limit, so it suits large database files.
phpMyAdmin’s upload limit prevents you from importing large SQL files directly through the interface. The command line bypasses this restriction and allows you to restore databases of any size.
You will connect to your server via SSH, navigate to your SQL file and run a single command to import it into your MySQL or MariaDB database. This method works for database backups, site migrations and restoring data after failures.
/home/user/ or /home/user/public_html.You will log into your server via SSH, navigate to the directory containing your SQL file and run the import command. The process completes in seconds for small files and may take several minutes for larger databases.
cd command to change to the directory where your SQL file is stored. For example, if your file is in public_html, run cd public_html. This makes the import command shorter and reduces the chance of path errors.mysql -u username -p database < mysql_file.sql, replacing username with your database username, database with your database name and mysql_file.sql with your SQL filename. The -p flag prompts you for your database password.The import runs immediately after you enter your password. You will see your command prompt return when the process completes. Your database now contains the data from the SQL file.
Large SQL files may take several minutes to import. If the process appears stuck for more than 10 minutes, press Ctrl+C to cancel and contact support for assistance.
Your database user needs appropriate privileges for the target database. Check user permissions in cPanel or Plesk and grant all privileges if necessary.
Character encoding mismatches cause display issues. Most WordPress databases use utf8mb4_unicode_ci as the collation. Check your database collation in phpMyAdmin and ensure it matches your SQL file’s encoding.
Imported databases contain the original site’s user credentials. You will need to reset your WordPress admin password to regain access.
You imported your SQL file into your MySQL or MariaDB database using the command line. This method bypasses phpMyAdmin’s upload restrictions and handles databases of any size. Your database now contains the imported data and is ready to use.
For smaller files under the upload limit, phpMyAdmin provides a graphical interface. You can also split large SQL files into smaller chunks or use alternative tools like Adminer. Our WordPress FAQs cover additional database management topics.
If you run into any trouble, get in touch and our team will be happy to help.
Did this guide solve your problem?
Our UK support team answers tickets and live chat every day. Send us the guide you were following and where it stopped working.
Related guides
cPanel hosting with the tools these guides use, backed by UK support.
Get cPanel HostingProtect your visitors with SSL certificates – from budget DV to premium EV certificates.
Get SSL Certificate