Import an SQL file directly via the MySQL command-line

If you have a very large database (totaling 10’s or 100’s of megabytes), then uploading via HTTP is not suitable. Instead, it will be quicker and more efficient to import the file directly into the database using the mysql command-line utility on the server.

However, to do this you will need SSH access to the server. If you do not have SSH access, please see our article:

To import an SQL file:

  • First, upload the file via FTP onto your account (into your private/ directory is best as no-one else can access this).
  • Using the SSH client of your choice, log onto the server. You will start at your home directory (/var/www/vhosts/, where is the domain the SSH account is associated with).
  • Run the following command line:
mysql -u username -p database < filename
  • where username is the username created for database. Finally, filename is the filename (and path, if required) to the file you just uploaded.
  • For example, if you created the database forum, with the username forum (and the password f0rum), and uploaded backup.sql to the private/ directory of your domain, you can run the following command:
mysql -u forum -p forum < private/backup.sql
Enter password:

If you see the error “Access denied for user 'username'@'localhost'“, check that you are using the correct username and password – this means that either one of them (or both of them) failed.

Depending on the size (and complexity) of the SQL file, this can take from a few seconds to a few minutes to complete. If you want to cancel command while it is running, press Ctrl & C at the same time.

Also, if you have a zipped or gzipped file, you will need to de-compress it before using it (the mysql command line utility will not understand the compressed file). To do this, run the following:

unzip path/to/


gunzip path/to/file.gz

If you still do not know how to do then just send email email
you can find my email in contact us
Thank You

Leave a Reply