MySQL数据库必备基操!!!(二)

一、临时表

1、临时表,无法使用show tables查看
2、临时表退出数据库即删除,也可用命令手动删除
3、临时表无法创建外键

mysql> create temporary table ls (id int(4) primary key auto_increment,name int(18) not null);
mysql> show tables;
+--------------+
| Tables_in_py |
+--------------+
| hsh          |
| hsh1         |
| hsh3         |
+--------------+
3 rows in set (0.01 sec)

二、用户授权

mysql> grant select on py.* to 'wangwu'@'%' identified by 'abc123'; #创建用户,只允许访问py库的表
Query OK, 0 rows affected, 1 warning (0.00 sec)
#注释
grant:提权
py.*:数据库py下的所有表,也可以指定表名
%:表示所有有,例“192.168.238.%,%.wh.com”

mysql> select user,authentication_string,host from mysql.user;
+---------------+-------------------------------------------+-----------+
| user          | authentication_string                     | host      |
+---------------+-------------------------------------------+-----------+
| root          | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| lisi          | *2517D5E7FDE154859781E63A4F8E06E9804EB170 | localhost |
| wangwu        | *6691484EA6B50DDDE1926A220DA01FA9E575C18A | %         |
+---------------+-------------------------------------------+-----------+
5 rows in set (0.00 sec)
mysql> mysql> grant all privileges on *tiantian'@'%' identified by 'abc123'; #允许用户在所有中断登录MySQL,并拥有所有权限
mysql> flush privileges; #刷新权限
Query OK, 0 rows affected (0.01 sec)

mysql> show grants for 'tiantian'@'%'; #查看权限
+-----------------------------------------------+
| Grants for tiantian@%                         |
+-----------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'tiantian'@'%' |
+-----------------------------------------------+
1 row in set (0.00 sec)
mysql> REVOKE ALL ON *.* FROM 'tiantian'@'%'; #撤销权限(需要大写)
Query OK, 0 rows affected (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值