How to import and export MySQL database via SSH

You can easily import/export your database using phpMyAdmin menu in cPanel, but when dealing with large databases over 50Mb it is recommended to manage them via SSH. In this article, I will cover exporting and importing a database via SSH. Make sure that you replace the following variables in the commands below:

USERNAME - the MySQL user assigned to your database.

DATABASE - the name of your MySQL database.

Exporting a MySQL database

To export a MySQL database, you need to use the mysqldump command. Here is the full command for exporting your database:

mysqldump -uUSERNAME -p DATABASE > backup.sql

You will be prompted for a password - this is your MySQL user's password.

The MySQL database will be exported to a file named "backup.sql" in your current directory.

Importing a MySQL database

To import a MySQL database, you need to use the mysql command. Here is the full command:

mysql -uUSERNAME -p DATABASE < backup.sql

Again, you will be prompted for the password of your MySQL user.

The backup.sql is the name of the file that you are importing to your database. It must be in your current working directory.

Video Tutorial


Is it not a great idea to follow me to be recieve my last posts? Follow me now!


How To Open Ports in CSF via WHM and SSH

This article will explain how you can open ports for your server in CSF through WHM and SSH.

Please be aware that opening ports on your server can be a security risk, please be aware of any risks when opening a specific port on your server.

There are 2 different ways to open ports on your server. One way is through WHM and one is via command line.

Steps to open ports in WHM

1. Log in to your WHM: SERVER-IP/WHM or SERVER-IP:2087

2. Click "ConfigServer Security & Firewall," which is under the "Plugins" section

 

CSF

 

3. Go to “Firewall Configuration”

 

Firewall Configuration

 

4. Find “TCP_IN=” under “IPv4 Port Settings”

Allow incoming RCP ports

 

5. Enter the port number in the list below. Make sure to separate ports with a single comma and do not enter any spaces.

6. Click “Change” at the bottom of the page.

 

This will reset the firewall so that the ports that you have opened will take effect.

Steps to open ports via command line

1. SSH into your server.

2. Go to the directory with the CSF configuration file.

cd /etc/csf/

3. Open the file “csf.conf” (In this tutorial I used "nano" editor)

nano csf.conf

4. Once you are in the configuration file, find "TCP_IN=", it will be under "# Allow incoming TCP ports"

5. Within the quotation marks, put the port number that you wish to open. Separate each IP using a single comma and no spaces.

6. Close the file and save all changes.

7. Restart the firewall.

csf -r

 

Video Tutorial


Is it not a great idea to follow me to be recieve my last posts? Follow me now!