2.MySQL 权限级别分为: 全局性的管理权限: 作用于整个MySQL实例级别 数据库级别的权限: 作用于某个指定的数据库上或者所有的数据库上 数据库对象级别的权限:作用于指定的数据库对象上(表、视图等)或者所有的数据库对象 3.查看mysql 有哪些用户: mysql> select user,host from mysql.user; 4.查看用户对应权限 select * from user where user='root' and host='localhost'\G; #所有权限都是Y ,就是什么权限都有 5.创建 mysql 用户 有两种方式创建MySQL授权用户
执行create user/grant命令(推荐方式) CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass'; 通过insert语句直接操作MySQL系统权限表 6.只提供id查询权限 grant select(id) on test.temp to test1@'localhost' identified by '123456'; 7.把普通用户变成管理员 GRANT ALL PRIVILEGES ON *.* TO 'test1'@'localhost' WITH GRANT OPTION;
查询当前数据库服务器所有的数据库 show databases; 选中某个数据库 use 数据库名字 test 查询当前数据库所有的表 show tables; 查询t1表所有数据 查询关键字 select * 所有 from 表名 select * from t1; 条件查询 id=2 where 条件 编程 if(条件 true){执行} select * from t1 where id=2; 查询id=2 pass =111 union 合并查询 2个特性: 前面查询的语句和后面的查询语句结果互不干扰 前面的查询语句的字段数量和后面的查询语句字段数量要一致
* == 3 select id from t1 where id=-1 union select * from t1 where pass =111;
order by 排序 order by 字段名字 id 也可以 跟上数字 1 2 3 4 .。。。。。