##############################################################
To create a backup user:
Create user ' backuser ' @ ' localhost ' identified by ' [email protected] ';
Grant Backup,select,insert,update,delete,create on DCOM.
to [email protected] ' localhost ';
Grant Show View,lock tables,trigger,select,insert,update,delete,create on DCOM.to [email protected] ' localhost ';
Update user set plugin= ' Mysql_native_password ', Password=password ("[email protected]") where user= "Backuser";
Flush privileges;
##############################################################
To deny Login resolution:
Update user set plugin= ' Mysql_native_password ', Password=password ("[email protected]") where user= "Backuser";
Backup error:
UPDATE mysql.user SET grant_priv= ' y ', super_priv= ' y ' WHERE user= ' backuser ';
##############################################################
To set up a secure login:
Mysql_config_editor Set--login-path=backtest--user=backuser--password
##############################################################
Deletion of the library:
Reported
Error 1010 (HY000): Error dropping database (can ' t rmdir '. \qpweb ', errno:41)
Delete the data file under Database Data directory while the library is running,
Re-build the library, and then import the data.
Show CREATE Database DCOM;
CREATE DATABASE DCOM
/!40100 DEFAULT CHARACTER SET UTF8 /
##############################################################
Backup:
Export only data from the database (without the table structure):
Mysqldump--login-path=backuser--add-locks-q-T DCOM > Test.sql
Export only the table structure (without data) in the database:
Mysqldump--login-path=backuser--add-locks-q-D DCOM > Test.sql
The Export-only table structure does not contain data:
Mysqldump--login-path=backuser--add-locks-q-t DCOM table name > Test.sql
Export-only data does not export table structure:
Mysqldump--login-path=backuser--add-locks-q-D DCOM table name > Test.sql
Back up all data:
mysqldump--login-path=backuser--add-locks-q DCOM > Test.sql
Recover data:
Use source whenever possible
MySQL--login-path=backuser-e "source Test.sql"
##############################################################
Build Library:
MySQL--login-path=test-e "CREATE DATABASE DCOM DEFAULT CHARACTER SET UTF8;"
Import Table structure:
MySQL--login-path=test-e "source/root/97tables.sql;" Dcom
Import data:
MySQL--login-path=test-e "source/root/sql/2018-03-28/t_admin_operator.sql;" Dcom
MySQL--login-path=test-e "source/root/sql/2018-03-28/t_admin_permission.sql;" Dcom
MySQL--login-path=test-e "source/root/sql/2018-03-28/t_admin_post_permission.sql;" Dcom
Query table data row count:
MySQL--login-path=test-e "SELECT count (*) from DCOM. T_admin_role; "
##############################################################
Back up the data in a table with a data table row count of not 0 in the database, excluding the table structure:
20,0-1 All
#!/bin/bash
Path=/opt/sql
Dir=mkdir $path/$(date +%Y-%m-%d)
dir1=$ (Date +%y-%m-%d)
MySQL--login-path=backuser-e "Show tables from DCOM" > $path/$dir 1/tables.txt
For I incat $path/$dir1/tables.txt
Do
Number=mysql --login-path=backuser -e "select count(*) from DCOM.$i" | tail -1
If [$number-GT 0]
Then echo "$i" >> $path/$dir 1/datanum.txt
else echo "$i" >> $path/$dir 1/nodatanum.txt
Fi
Done
For tables incat $path/$dir1/datanum.txt
Do
Mysqldump--login-path=backuser--add-locks-q-t DCOM $tables > $path/$dir 1/$tables. sql
Done
Rm-f $path/$dir 1/{datanum.txt,nodatanum.txt,tables.txt}
mysql5.6 use of essays