2. Enquiry
show databases; # #显示数据库
Use MySQL; # #进入mysql数据库
Show tables; # #显示当前库中表的名称
select * from user; # #查询user表中的所有内容
DESC user; # #查询user表的结构
3. Establishment of databases and tables
Create Database Westos; # #创建westos数据库
CREATE TABLE Linux (# #创建表linux
Username varchar (15) NOT NULL, # #username字段, maximum character length is not empty
Password varchar () NOT NULL
);
INSERT into Linux values (' User1 ', ' passwd1 '); # #给linux表中添加数据
INSERT into Linux values (' User1 ', password (' passwd1 ')); # #给linux表中添加数据, and password encryption
4. Update database Information
Update Linux set Password=password (' Passwd2 ') where username= ' User1 '; # #更新名字是user1的密码
Update Linux set Password=password (' 123 ') where (username= ' user1 ' or username= ' user2 '); # #更新user1, user2 password
5. Deleting a database
Delete from Linux where username= ' user1 '; # #从linux表中删除user1用户
drop table Linux; # #删除linux表
Drop database Westos; # #删除westos数据库
6. Backup of the database
Mysqldump-u Root-pwestos--all-database # #备份所有表中的所有数据
Mysqldump-u root-pwestos--all-database--no-date # #备份所有表 but does not back up data
Mysqldump-u Root-pwestos Westos # #备份westos数据库
Mysqldump-u Root-pwestos westos >/mnt/westos.sql # #备份westos库 and save the data to a Westos.sql file
Mysqldump-u root-pwestos Westos linux >/mnt/linux.sql # #备份westos数据库中的linux表
MYSQL-UROOT-PWESTOS-E "CREATE database Westos;" # #还原数据时, the corresponding Westos library should be established first
Mysql-uroot-pwestos Westos </mnt/westos.sql # #将数据导入westos库
MARIADB Database Simple operation