1、 进入数据库 mysql -u 用户名 -p 密码
2、 导出数据库 mysqldump -u 用户名 -p 密码 数据库名(表名)> 路径 备份.sql
3、 导入数据库 mysql -u 用户名 -p 密码 数据库名< 路径 备份.sql
或者进入mysql,使用source 路径 备份 此方法可以单独导入表
4、 显示所有数据库 show databases;
5、 使用数据库 use 数据库名;
6、 显示所有表 show tables;
7、 创建数据库 create database 数据库名;
8、 创建表 create table 表名(变量名 变量类型(大小)约束条件,变量名 变量类型(变量大小)约束条件,primary key(主键) );
9、 描述表 describe 表名;
10、向表中输入数据 insert into 表名 values( );
11、select 列 from 表 order by 列 desc/asc
select count(*) from 表名 统计表中记录总数
descending 降序排列的意思
ascending 升序排列
12、删除表内容
delete from 表名
truncate table 表名
13、更新表内容
update table 表名 set=' ' where 条件
14、改变表结构
alter table 表名 add id int(10) 【列名 数据类型】 增加列
alter table 表名 drop id 【列名】 删除列
alter table 表名 modify id int(6); 修改列
15、改变表名
rename table 表名1 to 表名2
16、查看数据库、表创建信息
show create database 数据库名
show create table 表名
17、过滤表中重复的信息
select distinct 列名 from 表名