Bobcares

CPanel Import Database via SSH

by | Oct 2, 2021

Let us discuss the CPanel import database via SSH.

Before we begin the import using mysqldump, we need to make sure we already have a MySQL database and MySQL database user.

As part of our Server Management Services, we assist our customers with several cPanel queries.

Today, let us see how our techs import databases via SSH.

 

CPanel import database via SSH

First and foremost, we can create a MySQL database and database user by accessing, cPanel -> MySQL Databases.

Similarly, prior to importing a database, we have to ensure that the SQL dumps are complete.

There is a quick method to check the SQL file integrity.

To do so, we use the following command to view the starting and ending lines of the dump:

(head;tail) < /$PATH/$TO/$DUMP.sql

Generally, a working example should look like the following.

Suppose the dump file is not properly terminated nor has a proper header. In that case, the file may be incomplete or corrupted.

[root@the ~]$ (head;tail) < /root/test.sql
-- MySQL dump 10.13 Distrib 5.7.34, for Linux (x86_64)
--
-- Host: localhost Database: cptest_test
-- ------------------------------------------------------
-- Server version 5.7.34

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-05-19 21:47:45

Once we finish creating both, we can import the database file with mysqldump command:

mysql -u database_username -p database_name < databasebackupfilename.sql

In most cases, this should resolve the query. However, if you still cannot perform the import, Bobcares is available 24*7.

[Need help? We are one click away]

 

Conclusion

In short, prior to the import, we need to create a MySQL database and database user. In this article, we saw how our Support Techs perform the import for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.