Several ways to backup MySQL
Recently have wanted to write some blog, but do not know what to write, feel that their recent knowledge has not increased, today I think of a blog can be written. Previously tried to backup MySQL according to the data folder, but never successful, a few days ago to help friends restore MySQL, and finally successfully restored the backup Data folder successfully.
MySQL database is the most commonly used database in the database, the operation of the backup is no exception. So let's share some of the ways MySQL databases are backed up today.
Way one: Use the command line.
The command line is quicker, just use the mysqldump command at the command line, which is in the bin directory of MySQL by default (if you need to add the bin directory to path), then open the command line, switch to a drive letter, and enter "Mysqldump–u ROOT–P database name > backup file name. sql ", click Enter, after entering the password, you can back up the corresponding database, this backup is not built in the statement of the library:
Mode two: Using client software such as SQLyog
I think using SQLyog software to back up MySQL database is simpler than other backup methods, and the way to recover it is simple. A database backed up with this software takes the SQL statement of the repository, which makes it easy to restore the database. Also useful navicat software to serve as MySQL client, sqlyog in use than navicat simpler. I'm used to this software, but sometimes I need to open multiple windows and use Navicat software. The SQLyog software interface is as follows:
If you want to back up the database, right-click the pop-up menu on the database that needs to be backed up, select "Backup/Export" from the menu, and then select the word to back up the SQL file from the popup menu:
In the SQL Dump window that pops up, you can back up the database by entering the name you want to back up. :
Method Three: Back up the Data folder
The reason why I write this blog is to say this way. Every time you need to reinstall the operating system, you need to back up all of the MySQL databases in the system, and if you take a backup of the way above, it's obviously bad. This is what I did before, the reason is that the restoration is always unsuccessful, so give up. This way, from the Internet and books, it is necessary to get the InnoDB of MySQL engine. This is the engine that is installed by default. Back up the time to back up the data folder in the MySQL directory, but later found that this method is not correct, you need to hide in the C-drive MySQL folder under the Data directory backup, that is the place to really save the MySQL data.
The following is the MySQL installation directory that can be seen and does not have our database as follows:
Next, we want to show the hidden files and find, in the folder Options, unhide the check box in front of the file as follows:
This will allow you to see the hidden folder of all users under the user folder in the C drive. As shown below:
In the folder under the MySQL folder under its directory, you can see the files of our current database. :
If we want to quickly remove or backup MySQL can be done using this method. If you want that, back up the folder that corresponds to that database. If you want to restore the database, just put it in this hidden directory.
Do not forget, after the operation, it is best to hide the original hidden directory again, to avoid the future deletion of files in the system.