找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手

MySQL数据库的权限设定,多表的方法

[复制链接]
本帖最后由 dcs68-李燕霞 于 2021-11-25 21:27 编辑

一,连接满足的条件:
  账号   root
  密码   123456
  端口   3306
  域名、ip地址  ifconfig查询的IP   localhost 192.168.22.1
  数据库需要重启 service mysqld restart
  防火墙要关闭   service iptables stop
  且对应的账号要拥有远程访问的权限(%)百分号权限

有%权限需要通过指令来赋予:1.use mysql  先进入数据库;
2,select host,user from user; 在查询即可,如果没有远程权限: grant all privileges on *.* to 'root'@'%' identified by '123456';

3,创建用户不赋予权限
新增加一个用户赋予本地访问权限,用户名称是qian
insert into user (host,user,password)values('localhost','qian',password('123456'));
4、创建用户后进行授权(方法二)
grant select,update,delete,drop on *.* to 'qian'@'localhost' identified by '123456'
5、查询指定用户拥有哪些权限
show grants for 'qian'@'localhost';
6、取消指定用户的权限
revoke all on *.* from 'qian'@'localhost';
7、删除用户
delete from user where user='qian' and host='localhost';
8、改用户密码
在user表中把root用户的密码改为123456
update user set password=password('123456') where user='root';

二,多表查询的方法
1、多表的条件:必须要关联的表中有相同的字段
基本连接:常用的方法
     1,select * from 表1,表2 where 表1字段=表2字段(表一字段与表二字段一样)
     2,内连接:inner join on
     3, 左连接方法:左边的表为主表,右表为子表,     left join  on
     4,右连接:右表的表为主表,左表为子表,right join on
     5,union连接方法,此方法连接是必须多个表字段要相同,select * from 表1 union select * from 表2

分享至 : QQ空间
收藏

0 个回复

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