找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
查询语句
select  * from  表名     ;                                查看全部数据
select    字段 ,字段  from  表名    ;                       查看字段内容     

where 条件语句
       select id from wuhan3 where id =5         限定条件查询
            or         and
            =      <=       >=      <     >       !=            mysql 当中的比较符号
select  id from wuhan3  between 1   and   3
in        not in
        一个属于 select * from wuhan3 where id in(2,4);
已不属于 select * from wuhan3 where id not in(2,4);

is null  is not null  (查询为空与不为空的数据)
          select * from wuhan3 where name is   not  null;
limit  (查询限定范围)
select * from   wuhan3  where  id limit  2,1;     第二行往下一行

update   表名  set  字段 = 数值  where   条件
    update wuhan3 set phone=166456233211456  where id=2;

            update 我们在修改表数据的时候,一定要注意要加修改的条件
     不然就会全部进行修改
like        模糊查询
select   *from    wuhan3    where    phone  like ‘15%
order  by   排序查看
select  * from wuhan3  order by  id  asc/desc(升/降)


mysql聚合函数

·        mysql 重装出错的原因:删除方式有问题没有卸载mysql程序
rm进行删除的时候也没有删除干净mysql的配置文件,从而导致再次
安装时候报错

group by
一般是接聚合函数使用,不能和分组以外的字段结合使用
那么接其他字段他不会报错,但是会造成数据混乱
select  字段  ,字段 from 表 group  by   字段 having   字段限制
   

group by 后面不能接where使用,如果要接查询条件的话用having进行
接条件,having的作用相当于where
count(*)统计
select  count(*)from  wuhan3  字段
max  min  svg(平均) sum(和)
select  max/min/svg(字段)  from 表

取别名
select   max(id)  as   a from  表

表备份
create  table  wuhan4 like wuhan3
insert  into wuhan4 select *from wuhan3;
insert into wuhan4(字段,字段) select 字段,字段 from wuhan3

备份,只是备份表结构,并不会备份表数据


备份数据库
mysqldump -u root -p123456  wuhan3>/wuhan3.sql
先建库在导入
mysql    -u  root -p123456  wuhan3</wuhan3.sql
备份一个数据库,进行还原时,sql文件进行还原到某一个数据库当中
所以说还原时,新建一个数据库进行还原。
用户权限       
在mysql库root用户
insert  into  user  (host,user,password)values(‘localhost’,‘erdan’,password(‘123456‘)
flush  privilege;                                                                权限刷新
show  grants   for 'erdan'@'localhost';                                   查看用户权限
grant  select  ,delete on *.* to 'erdan'@'localhost' identified by '123456' ;
         修改增加用户选择,删除权限


分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册