Home > database >  Mysql basic backup recovery operation
Mysql basic backup recovery operation

Time:09-27

1. Give the root user password Mysql -u root passwd 123. com '(plaintext password) Mysqladmin -u root -p passwd (modify password)

2. Login Mysql Mysql -u root -p
3. Check the database name show databases
4. Use links database [name]
5. Create a database create databases [name]
6. Check the table Show tables
7. Create the tables the Create table [table name] (int id, name char (20), sex char (20))
8. To add data Insert into biao1 values ()
9. Update the data Update [table name] set name='modified name where id=1 (id) to modify the
10. Add more data Insert into the table name Select UnionSelect () ()
11. The query data Select * from table name;
12. View the first three lines Select * from table name limit 3
13. See the table structure Desc table name
14. Add fields Alter table table name add the column field (types)
15. Modify the fields the Alter table table name change old field name new type of field name
16. Add more fields Alter table table name add (field type, field type)
17. The backup database syntax: mysqldump -u username - p library name table name & gt;/backup file path/backup file name
18. The designated database backup Mysqldump -u root -p library name & gt; SQL
/bak. ABC.19. Multiple database backup Mysqldump -u root -p - database library name 1 library name 2 library name 3 & gt;/bak/SQL
20. Backup all database Mysqldump -u root -p - all - database & gt; SQL
/bak/all.21. Restore the database: the Mysql -u root -p library name & lt; Backup path/backup file name
22. Restore specified tables in Mysql -u root -p table name & lt; Bak/biao. Note: SQL when restore the database, or recover data table should be to create a good first specify the library name
23. The incremental backup log Cd/usr/local/mysql/dataVim/etc/my mycnf in mysql after adding the log - bin=mysql - binSystemctl restart mysqld to view the log file Mysqlbinlog mysql - bin. 00001 backup log mysql -u root -p flush - logsCp mysql - bin0000.1/bak/1 recovery: Mysqlbinlog - no - defaults -- - start - position="start" -- - stop - position='end' nodes'/bak/1 mysql -u root -p - start - a datetime="time" - - stop - a datetime="time"
24. The authorized Mysql> database; Grant all permissions (operation) on *. * to 'zhangsan' @ '192.168.1.2 instead' (network) database to be authorised identified by "123. com" database username into the fruit without authorization command will create the user directly and set up the authorization code, the client can be installed a database or install yum - y install mariadb Mysql -u zhangsan 192.168.1.1 - p - p - h 3306
25 revoke permissions: mysql> Revoke the delete on *. * ffrom "zhangsan" @ "192.168.1.2 instead
26 look at the current user permissions; Show grants;