• 创建用户


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


     表示给用户test在本地登陆时添加了对testDB数据库的全部表的不论什么操作。若想指定权限的话。可将all privileges修 改为select或update或delete或三者的组合。若想指定表的权限,能够将testDB.*改动为testDB.info表示可对testDb数据库中的info表进行操作;若想指定訪问的地址,可将@%改动为localhost表示用户test仅仅能在本地进行对数据库的操作。



  • 刷新系统权限表


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

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