登录:mysql -uroot -p
显示所有数据库: show databases;
使用数据库: use qiu1;
显示表: show tables;
查询表中所有记录:select * from qiu1;
查询某一类的记录:select 某字段 from qiu1 where name="条件约束";
查询某一类的记录(模糊匹配):select 某字段 from qiu1 where name like "条件约束%";
查询表中所有关于qiu记录:select * from qiu1 where name="qiu";
取消所有命令: \c
退出mysql: exit;
新建用户:grant all on qiu1.* to "user"@"127.0.0.1" identified by "123456";
建立数据库: create database qiu2;
建立表:create table student(id int(10) primary key auto increment,name varchar(10),score int(2));
查看表的结构: desc student;
插入数据:insert into student (id,name,score) values(25874,"zhangsan",98);
删除数据库: drop database qiu2;
执行外部文件的命令: source 文件名.sql
字符集:default character set utf8
显示版本信息:select version();
显示当前使用的库: select database();
更新信息:update student set name="me" where id=5; //注意:如果不指定,则所有信息都会被更改
限制数据的数量:select * from student limit 2 order by id; //limit 关键字limit限制数量;order by 排序 先排序,再截取