mysql之常用SQL语句

查看数据库
show databases;
1
进入切换数据库
use 数据库名
use crushlinux;
12
查看表
show tables;
1
新建数据库,新建表
create database 库名;
 create database yi;
create table 表名(字段一,字段2);
create table yi(name char(14) not null , password char(23) not null default '' ,primary key(name));
1234
查看表中字段
desc 表名
 desc yi;
12
查询
select 字段 from 表名 where 条件;
select * from users;
12
插入数据
insert into 表名(字段一,字段二...)  values(值1,值2....)
insert into yi values('zhangsan','123');
12
更新数据
update 表名 set 字段=值 where 条件;
update yi
    -> set
    -> name='lisi'
    -> where name='zhangsan'
    -> ;
123456
删除数据
delete from 表名 where 条件;
delete from yi where name = 'lisi';
12
设置用户权限(用户不存在是创建)
grant 命令 on 数据库名.表名  to 用户名@地址  identified by ‘密码’
grant all on *.* to user1@'192.168.200.1' identified by '123';
12
刷新授权表
flush privileges;
1
查看用户权限
show grants for root@地址
show grants for 'root'@localhost;
12
撤销用户权限
revoke 权限列表 on 数据库名.表名 from 用户名@地址
1
显示服务器状态信息,权限信息
show status
show grants
12
显示当前时间
show now();
————————————————
版权声明:本文为CSDN博主「风之老凌」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42480196/article/details/102480411
posted @ 2020-03-05 11:04  奥义,三千世界  阅读(114)  评论(0编辑  收藏  举报