数据库-基础命令

数据库基本-命令

#查看所有逻辑数据库

[root@localhost ~]# show databases;

#创建数据库t1

[root@localhost ~]# create database t1;

#删除库t1

[root@localhost ~]# drop database t1;

#使用数据库

[root@localhost ~]# use t1;

#建表并添加两个字段

[root@localhost ~]# create table test(age tinyint, number int);  #(字段 数据类型)

#添加字段

[root@localhost ~]# alter table t1 add math int;

#条件查询

[root@localhost ~]# select id,name from employee5 where id<=3; 

#去重sex

[root@localhost ~]# select distinct sex from employee5;

#数据库授权(指定来源用户及ip地址)

[root@localhost ~]# grant all on 数据库. to ‘用户’@'客户端来源IP地址' identified by‘密码’

#查询数据库下所有用户及权限

[root@localhost ~]# select * from mysql.user;

#查询数据库的用户及权限

[root@localhost ~]# select * from mysql.db  where user='用户'\G

#查询数据库中表的用户及权限

[root@localhost ~]# select * from mysql.tables_priv where user='用户'\G

#刷新数据库

[root@localhost ~]# FLUSH PRIVILEGES;  
补充:通配符  
           ?匹配单个字符
           * 匹配任意长度的任意字符

欢迎大家参考交流!

Guess you like

Origin blog.csdn.net/weixin_52099680/article/details/110094721