One of the big problems that occurs when backing up webmasters is the problem of importing large databases. In this article, we are going to teach database import in ssh and fix this problem.
In this article, increasing the volume of uploads to phpmyadmin we solved the problem of those who encountered php limitations during database import via phpmyadmin, but what if your database size is about 10 to 20 gigs?
Certainly in such cases the import operations are not performed properly and due to the large volume of databases it would not be wise to do so. In some cases, if you want to move a website, for example, from a web directory with an admin directory to a new one with a 30-panel host, you have to manually transfer and use the database import method in ssh.
How to Import Database in ssh
Step One: First, login to your ssh server with root access via putty.
Step Two: Then download the site database file to the server, you can use the wget or curl command.
The Step 3:
Then you need to increase the max_allowed_packet parameter in my.cnf file, which specifies the maximum amount of received packets and is very effective in importing database ssh speeds. We recommend that you back up it before making any changes to the file. The default path for this file is in the / etc directory.
There are two ways to import a database into ssh First login to the user panel and start building a new database and a dedicated user by training the database builder in mysql ;
then import the database through ssh.
mysql -u dbuser -p dbname <database.sql
Quite obviously, instead of dbuser you enter the username you created through the panel,
instead of dbname the database name is created, and instead of database.sql you enter your database file path.
Note: Enter this command in the directory where your database file is located.
If you also want to import the database file with root access to mysql you can use the following command to import the database into ssh.
mysql -u root -p dbname <database.sql
After you hit Enter you will be prompted for the database root password which starts with importing that database into ssh and depending on the server hardware,
the database size, max_allowed_packet parameter and your internet speed may vary.
Using the above mentioned method to import the database into ssh for the type of access
and reliability will cause the least error and problems during import.
Note: If you are hosting multiple sites on your server,
we recommend postponing your database import time to ensure
that there is the least amount of traffic on the server to slow down and in some cases slow down your server. Don’t.