MySQL

MySQL用户操作

2018-09-28  本文已影响0人  张张张啊先生

注意:

一、查询用户

SELECT Host,User FROM mysql.`user`;

二、创建用户

CREATE USER 'username'@'host' IDENTIFIED BY 'password';
  CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
  CREATE USER 'dog'@'192.168.6.70' IDENDIFIED BY '123456';
  CREATE USER 'dog'@'%' IDENTIFIED BY '123456';
  CREATE USER 'dog'@'%' IDENTIFIED BY '';
  CREATE USER 'dog'@'%';

三、修改用户名

UPDATE mysql.`user` SET USER = 'newUsername' WHERE USER = 'oldUsername';
FLUSH PRIVILEGES;//刷新系统权限表
UPDATE mysql.`user` SET USER = 'test2' WHERE USER = 'test';
FLUSH PRIVILEGES;//刷新系统权限表

四、删除用户

DROP USER 'username'@'host';
或
DELETE FROM mysql.`user` WHERE USER = 'username' AND HOST = 'host';
FLUSH PRIVILEGES;//刷新系统权限表
DROP USER 'test'@'%';
或
DELETE FROM mysql.`user` WHERE USER = 'test' AND HOST = '%';
FLUSH PRIVILEGES;//刷新系统权限表
上一篇 下一篇

猜你喜欢

热点阅读