mysql新建用户和赋予权限

  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 );

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容