mysql-DCL语句(数据控制语言,进行授权与权限回收,如grant、revoke)

一、创建用户

        (1)mysql中用户的组成

                

         (2)用户创建语句

                create user ‘username’[@’host’ ] [identified by ‘password’]

                        [@’host’ ]:可以省略,默认是%

                        [identified by ‘password’]:表示设置密码,如果没有指定,密码默认为空
二、删除用户
        drop user ‘username’[@’host’];
        
三、修改密码
        update user set password =password(’ 新密码 ’) where 条件
                 password 密码 ): 对数据进行加密
                

         执行flush privileges;后才会生效

                

四、授权

        grant all privileges on 库名.表名 to ‘user’[@’host’]

                all privileges:所有权限
                on:哪个 xxxx 库和表的权限
                to:给 xxxx 用户
                含义:授予所有库下所有表的所有权限,给指定用户
        常用写法: grant all privileges on * . * to ‘user ’[@’host’]
                             ----将mysql中所有库所有表的所有权限授予指定用户

 五、刷新权限语句

        flush privileges;

        ---确保权限修改后即时生效

猜你喜欢

转载自blog.csdn.net/chengdiyiyo/article/details/121020943