mysql backup restore CRUD

1.1 CRUD

1.1.1 Log database: mysql -u root -p

 

 

 

1.1.2 Create a database: create database app;

 

 

 

1.1.3 Switch to app database: use app

1.1.4 Create a table

create table name1 (id int(10),name char(20) default '', primary key (id));

create table name2 (id int(10),name char(20) default '', primary key (id));

 

 

 

 

 

 

See Table 1.1.5 show tables;

 

 

 

 

1.1.6 View table structure describe name1;

 

 

 

1.1.7 Insert Data

insert into name1 (id,name) values ('1','zhaoliying') ;

insert into name1 (id,name) values ('2','xiaozhan');

insert into name1 (id,name) values ('3','yangmi');

insert into name1 (id,name) values ('4','zhangjie');

 insert into name2 (id,name) values ('1','linyuner');

insert into name2 (id,name) values ('2','luhan');

 

 

 

1.1.8 View table data

select * from name1;

 

 

 

See 1.1.9 a data line: select * from name1 where name = 'xiaozhan';

 

 

 

1.1.10 View 1 data: select name from name1;

 

 

 

 

1.1.11 Update Data: update name1 set name = 'chenglong' where id = '3';

 

 

 



1.1.12 Check for updates select * from name1; ## you can see the third line has been updated

 

 

 

A data 1.1.13 Delete: delete from name1 where name = 'zhangjie';

 

 

 

1.1.14 Check whether to delete the data: select * from name1;

 

 

 

1.1.15 authorization:

grant all on *.* to 'qi'@'localhost' identified by '123456.Com';
 exit

 

 

 


1.1.16 Use qi account login: MySQL -uqi -p123456.Com

show databases;

exit

 

 

 

 

1.1.17 use root account login: mysql -uroot -p123456

 

 

 

1.1.18 to see what the user is authorized: select user, host from mysql.user;

 

 

 

1.1.19 View authorization permissions: show grants for 'qi' @ 'localhost';

 

 

 

1.1.20 delete authorization permissions: revoke all on * * from 'qi' @ 'localhost';.

 

 

 

 1.1.21 Check whether to withdraw permission: show grants for 'qi' @ 'localhost';

 exit

 

 

  1.1.22 delete database

 

 

  1.1.23 Delete table

 

 

Backup Restore 2.1

2.1.1 explain

mysqldump -u username -p [Database Name] [Table Name]> / backup path / file name of the backup   
 
mysqldump -u username -p --databases library name 1 [library name 2] ......> / backup path / backup file name
 
mysqldump -u user name -p --all-databases> / backup path / backup file name

2.1.2 Start Backup
 mysqldump -u root -p App NAME1> /root/app_name1.sql
 mysqldump -u root -p --databases App> /root/app.sql
mysqldump -u root -p --opt --all- databases> /root/all.sql

 

 

 

 

 

 

2.1.3 restore
MySQL -u the root -p123456
 drop Database App;

exit;

 

 


mysql -u root -p < /root/app.sql

 

 


 mysql -u root -p123456

show databases;

mysql> use app;

show tables;

 

Guess you like

Origin www.cnblogs.com/xiaolxy/p/12568559.html