Export and Import Database in CentOS/Ubuntu Server
We can easily export and import MySQL/MariaDB database in CentOS or Ubuntu server.
- SSH access to Linux sever.
- The database credentials.
Login to your server via SSH. You need the
username of the database and the
user password. Now run this command to export the database:
sudo mysqldump -u USERNAME -pPASSWORD DATABASE_NAME > database_name.sql
USERNAME– The username of the database.
PASSWORD– The password of the user.
DATABASE_NAME– The database name you want to export.
database_name.sql– This will be the exported .sql file which will be stored in the current directory (the SSH server’s current path).
At the time of exporting, if there is any problem, mysqldump will print the error.
sudo mysqldump -u obydul -pTest1234 test_db_1 < dump.sql
Login to the database as root (or root access username).
mysql -u root -p
We are going to create a new database called 'new_database'.
CREATE DATABASE new_database;
Exit the MySQL by typing
Now go to the directory where the .sql file is located. Then hit this command to import the database:
sudo mysql -u USERNAME -pPASSWORD new_database < database_name.sql
USERNAME- The username of the new database.
PASSWORD- The password of the user.
new_database- The database name where you want to import.
database_name.sql- This database will be imported.
sudo mysql -u obydul -pTest1234 test_db_2 < dump.sql
You can learn more from official mysqldump documentation page. Thank you. ?
Preview may take a few seconds to load.
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Bold **double asterisks**
Three back ticks and then enter your code blocks here.
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
> type a greater than sign and start typing your quote.
You can add links by adding text inside of  and the link inside of (), like so:
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of , and the image URL inside of (), like so:
To add a divider you can add three dashes or three asterisks:
--- or ***