美文网首页
mysql新建用户和赋予权限

mysql新建用户和赋予权限

作者: 麦田夕阳 | 来源:发表于2019-11-17 11:53 被阅读0次
  1. 登录数据库:mysql -u root -p

  2. 新建用户
    2.1 create user 'newuser'@'%' identified with mysql_native_password_by 'fjh321';(mysql8)
    2.2 create user 'newuser'@"%" identified by ''fjh321";(mysql5.7)

  3. 授权
    3.1 grant all privileges on . to 'fjh'@'%';
    3.2 grant insert select delete update on . to 'fjh'@'%';
    3.3 grant all privileges on 数据库.* to 'fjh'@'@';
    3.4 flush privileges;

  4. 显示账号及权限相关信息
    4.1 show grant for 'fjh'@'%';
    4.2 show create user 'fjh'@'%';

  5. 撤回用户权限
    5.1 revoke all privileges on . from 'fjh'@'%';

  6. 删除用户
    drop user 'fjh'@'%';

  7. 创建数据库
    create database dataBaseName;

  8. 创建表
    create table tableName( id bigint not null );

相关文章

网友评论

      本文标题:mysql新建用户和赋予权限

      本文链接:https://www.haomeiwen.com/subject/wkrpictx.html