Mysql 数据库 用户相关操作指令

新建用户:

mysql>use mysql;
mysql>insert into user(user,host,authentication_string) values('test','%',password('1234'));
mysql>flush privileges;

退出登录试验一下。

修改用户密码:

mysql>use mysql;
mysql>update user set authentication_string=password('123456') where user='test';
mysql>flush privileges;

删除用户:

mysql>use mysql;
mysql>delete from user where user='test' and host='localhost';
mysql>flush privileges;

授权用户数据库权限:

mysql>grant all privileges on testDB.* to test@localhost identified by '1234';
mysql>flush privileges;

授权用户数据库部分权限:

mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges;

授权用户远程登录:

mysql>grant select,updateon testDB.* to test@"%" identified by '1234';
mysql>flush privileges;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容