You can use the following commands to back up and restore databases of any size on Linux servers.
For this operation, you need to have a Server Rental, Cloud or Server Hosting service and be able to access your system via SSH. Although the example commands are specified for the Linux operating system, you can also perform the same operation on Windows Servers through the .exe files found in the bin folder under the relevant MySQL directory.
For database backup, apply the following command;
mysqldump -u username -p databasename > databasefile.sql
In the above command, enter the information you defined when creating your database in the username and databasename fields as indicated. When you press Enter, you will be asked for your database password. After entering your password, the backup process will begin.
To restore the database you backed up with the above method, you can apply the following command;
mysql -u username -p databasename < databasefile.sql
After typing this command, you can enter your database password and start the restore process.
To run the same commands on Windows servers, you can go to the mysql/bin directory and use the mysqldump.exe and mysql.exe program files with the same parameters.
If you want to load as MySQL root and do not know the MySQL root password, you can find it out as follows.
Finding MySQL Root Password
First, we connect to our server via SSH. Then we type the following line in the command line and press enter.
cat /root/.my.cnf
The information that appears on the command line screen looks like the following. In this section, what is written opposite “ password= ” is your password.
password= yourmysqlrootpassword
user=root
This way, you can find out your current MySQL root password without changing it.
Leave a Comment
* Your comment will be published after approval.
Comments
0No comments yet. Be the first to comment!