Usually, when dealing with MySQL database imports or exports, customers utilizing a cPanel hosting server will use PHPMyAdmin to do the job. While it is convenient and intuitive to use, it does come with limitations in terms of the import/export speed and the size you are allowed to import at once (50MB). In this article, we will be looking at a method you can use to import or export your database when dealing with a database of a bigger size.
Import a MySQL database via SSH
Please follow these steps:
1. Please login via SSH.
2. Use the SSH commands basics to navigate to the directory where the SQL file is located. Upon entering this directory, please execute the following command:
mysql -uMYSQL_USER -p DATABASE_NAME < FILE.SQL
Here is an example of how the command will look like:
mysql -uarmada_user -p armada_database < backup.sql
3. Upon typing the above, you will receive a prompt requesting the database password. Please type it in and press the "ENTER" button on your keyboard.
4. Depending on the size of the SQL, you will have to wait a few seconds or even minutes. Upon completion, your command-line interface will be returned to its default position, showing something simar to:
[user@host ~]$
That's when you know the importation process is done.
Export a MySQL database over SSH
Here are the steps needed to export a database over SSH:
1. Please login via SSH.
2. By default, you will be placed within the home dir of your hosting account, and you can run the export command here, however, if you want to export it within a specific folder, please follow the SSH commands basics to navigate to the desired directory.
3. Once you arrive in the folder you wish to export the database in, please execute the following command:
mysqldump -uMYSQL_USERNAME -p DATABASE_NAME > FILE.SQL
You can give this SQL file whatever name you wish to. Here is an example of how the command will look like:
mysqldump -uarmada_user -p armada_database > backup.sql
4. You will be prompted to enter the database password. Upon doing so, the export process will begin, and it will take from a couple of seconds to a few minutes based on its size. After the command finishes its execution, your terminal will be returned to its default position, showing something simar to
[user@host ~]$
That's when you know the export is done.