There are necessary tools on many control panels to take a MySQL backup, and taking a MySQL backup is quite simple. In this article, we will provide you with information about how to take a
MySQL backup via command.
In cPanel, MySQL databases are located in the /var/lib/mysql directory. To take a backup of any site, you first need to navigate to this directory. First, we navigate to the directory where the databases are located with the following
commands.
cd /var/lib/mysql
ll
To take a MySQL backup with a command, you will need the server’s MySQL password. We print this password to the screen with the following command.
cat /root/.my.cnfAfter
printing our password to the screen, we can now take our MySQL backup. You need to apply the following command for this operation.
mysqldump -u root -p veritabanı > yedek.sqlWhen you run the command, it will ask for a password. After
copying and pasting the MySQL password we printed to the screen, we confirm with the Enter key. After confirmation, it will start processing and the command line will become inactive. After taking the MySQL backup, the command line will become active again. After the
process is complete, you can list the contents again with the ll command and see the backup you took as yedek.sql.
Restoring a Backup
If you have a previously taken MySQL backup and want to import it, you need to use the following
commands. Since the server MySQL password is required during the backup restore process, we first print our password to the screen and then proceed.
cat /root/.my.cnf
Password on Screen
mysql -u root -p veritabanı <
yedek.sql
After applying the command, we again enter our password and confirm with the Enter key and wait for the process to finish. After the process is complete, the database will have been imported.
Leave a Comment
* Your comment will be published after approval.
Comments
0No comments yet. Be the first to comment!