1、cmd如何切换mysql配置文件文件(目录自己找)

2、如何进入mysql

3、查看数据库列表

4、创建数据库 create database 数据库名称(不能纯数字)

5、如果遇到报错如下

解决方式是:
打开mysql的配置文件,修改一句代码就可以了

6、使用数据库 use 数据库名称;

7、设置字符集为utf8 set names utf8;

8、只要use了数据库,紧接着就必须设置字符集
9、几乎每张表内都有主键 primary key
10、自增 auto_increment
11、创建数据表案例
create table `user`( -> `id` int(11) not null primary key auto_increment, -> `username` varchar(50) not null, -> `password` varchar(50) not null -> );
MYSQL命令解析:
create table `表名`( -> `主键名称` int(11) not null primary key auto_increment, -> `字段名` 数据类型(长度) not null, -> `字段名` 数据类型(长度) not null -> );
- 删除数据库 drop database 表名;

- 创建数据库 create database 表名;

- 查看数据库列表 show databases;

- 使用某一个数据库 use 表名;

- 查看某一个数据库下的数据表 show tables;

- 创建表格

- 查看表结构 desc 表名;

- 给一张表添加数据 : insert into `表名` values(null,字段值)

- 查看一张数据表的内容 select * from `表名`;

- 指定字段的查询 select id ,name from `表名`;

- 条件查询 - 倒叙展示 select * from `表名` order by `id` desc; 正序asc 倒叙order

- 条件查询-判断 select * from `表名` where `s_age`>18 and `s_sex`='男';

- 条件查询-在...之间 between...and...
- select * from `表名` where `s_age` between 19 and 21;

- 条件查询-精确查询 select * from `表名` where `id` = 1;

- 条件查询-in查询 select * from `表名` where `id` in(1,3,5,7);

- 条件查询-模糊查询 select * from `表名` where `s_name` like '%张%';

- 分组查询
-
select count(*) as num from `student` group by `s_sex`;
- 修改数据 update `表名` set `字段1`='值1',`字段2`='值2' where 条件

- 将主键id为246的性别改为女

只有表名和字段名用到的是``
值用到的是 ''
类型不加单引号
删除某一条数据 delete from `表名` where 条件
delete from `student` where `id` =1;



成功的秘诀,在永不改变既定的目的~