mysql、添加和删除用户、添加权限

  • 创建用户
     mysql>insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
     添加了一个username为test、password为1234用户。但该用户仅仅能在本地登陆,若想远程登陆的话可将localhost改为%表示不论什么一台电脑都能够登陆。或改为特定的ip表示仅仅能在特定的ip地址上登陆。
  • 为用户加入权限
     mysql>grant all privileges on testDB.* to test@localhost identified by '1234';
  • 刷新系统权限表
     mysql>flush privileges;
  • 删除用户
     mysql>Delete FROM user Where User='test' and Host='localhost';
  • 删除账户及权限
     mysql>drop user username@'%';
  • 改动用户password
     mysql>update mysql.user set password=password('新密码') where User="test" and Host="localhost";

版权声明:本文博主原创文章,博客,未经同意不得转载。

原文地址:https://www.cnblogs.com/hrhguanli/p/4851957.html