How to Install MySQL Database via SSH?

Managing large MySQL database tables through PHPMyAdmin can be quite challenging. However, you can perform this task faster and easier using SSH (Secure Shell). Here is our step-by-step guide:

Step 1: Backup and Download the Database
First, back up your existing MySQL database as a .sql file and download it to your computer. If the file size is large, compress (zip) it for faster download.

Step 2: Establish SSH Connection
Connect to your server via SSH and log in as the root user.

Step 3: Download the Backup File to the Server
If you have uploaded your backup file to a website, download it to the server using the following command:
wget http://www.yoursite.com/backup.sql

Step 4: Navigate to the Directory
Change directory to where your backup file is located on the server.

Step 5: Import the Database
Import the backup file into the database using the command:
mysql -u database_username -p database_name < backup.sql
After running this command, enter your password. If you do not encounter any errors, your database has been successfully imported.

Step 6: Backup the Database (Optional)
If you want to back up your database, use the following command:
mysql -u database_username -p database_name > backup.sql
This command creates a backup of your database that you can safely store.

Did you find it useful?
(32 times viewed / 0 people found it helpful)