In this short tutorial I will show you how to import your database to any server/hosting with access to command line using just some basic server knowledges.
In this short tutorial we will show, how to import large database using SSH Command Line. Most of the people who use the shared hosting, have ever tried to import large databases from PhpMyAdmin, that weight more than 100Mb, and most of them met various difficulties during this process. On this way may appear some errors, like:
You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.
No data to import. Either no filename was sent or the filesize exceeded the maximum allowed size. See FAQ 1.16.
Unfortunately, all shared servers have a limit of 50MB or so for database upload from PhpMyAdmin, which in most cases is integrated in the cPanel. It is a global setting on the server that cannot be changed and not all the time this issue can be fixed just by editing php.ini file and increasing
Sure, it is possible to contact hosting support team and ask them for help, but if you can’t wait or the hosting doesn’t answer, and you want to import the database quickly, without any errors, then yo can follow up our guide.
Using SSH can be a great way to manage the database and files on the website. By using some simple commands you can import a large MySQL database into a recently created database on your hosting.
Import the large database from Cpanel Terminal
First, make sure that the hosting provider supports SSH Access. You can check it from your cPanel Account here:
If it does, then you must export the database in .sql format. It can not be compressed in a .zip or .tar.gz file.
Then follow the steps below:
- Upload the SQL file that you exported to the root folder(public_html for ex.) via the cPanel file manager or an FTP client.
- If the database does not exist, please create a database, a user with a strong password, and give the user full privileges to the database. Save the username and password in the text file.
- Log into the server through the Terminal from cPanel.
- Type in this command:
mysql -p -u user_name database_name < file.sql
(replace ‘user_name’, ‘database_name’, and ‘file.sql’ with the actual name.)
- The system will ask for the database user password, and then the database will be imported. Note: the password is invisible!
We recommend using the database user with the database user’s password and not the cPanel main user and password. The -p flag will cause the MySQL to prompt for your account’s password. Do not put passwords in the command line in the plain text, and let the system to prompt for a password. This is for your own security.
That’s it. In case you have any questions, please feel free to ask here in comments.