Mysql optimization tips-regular maintenance (regular backup)

1. When we use grouping, we can turn off the default sorting

select * from stu group by name order by null;

2. When we query the join table, left join on is more efficient than other joins? have a question

 

3. Choose the right engine

Generally, if you need a transaction that can be rolled back, you need to use the innoDB engine for high security, but the execution efficiency of this engine is not as high as myisam.

Nothing has the best of both worlds, safety must sacrifice efficiency

The locking mechanism is also more efficient to lock a table than to lock each row.

 

Database backup: manual backup, timer backup

Starter version of timer backup

At the same time, creating a bat like this will overwrite the original file every time the backup is made

How to configure the timer Right click on My Computer--->Manage-->Create Task Schedule Configuration Parameters

 

 

Advanced version of the timer backup process

1. First, create a Java script or php script containing SQL backup statements. Random file names can be generated in the script to prevent the backup data from being overwritten

mysqldump -u root -proot database name table name>d:\ randomly generated file name (here you can use random or new data() or hash)

2. Create a .bat file. The file is a statement that can parse a java script or a php script 

       1. The parser that parses php scripts is generally php.exe

       2. Parse the java script javac.exe and java.exe to compile and execute the java file

Third, create a timed task to execute the bat file regularly, then the bat file runs the script file, and the script file executes the database backup statement

 

 

Guess you like

Origin blog.csdn.net/weixin_41421227/article/details/88829889