MySQL权限管理常用命令

1、进入mysql命令行。

 

(1)SSH连接:
mysql -u root -p
输入root密码

 

(2)Navicat for MySQL中:
右击连接,选择“命令列界面..”

 

2、mysql环境操作

 

(1)创建用户
Mysql> create user 'USERNAME'@'%' identified by 'PASSWORD';
Mysql> create user 'ljf'@'%' identified by '123456';
注:% 匹配任务访问来源,任意IP

 

(2)更改用户名
Mysql> rename user OLD_NAME to NEW_NAME;
Mysql> rename user ljf to zy;

 

(3)修改密码
mysql> set password for 用户名@localhost = password('新密码');
mysql> set password for ljf = password('ljf123');

 

(4)查询所有用户
mysql> select user,host,password from mysql.user;

(5)删除用户
Mysql> drop user 'USERNAME'@'HOST';
Mysql> drop user ljf;

 

(6)用户授权
Mysql> grant all on rulian.* to ljf@'%' identified by '123456';
Mysql> grant select,insert,update,delete,alter,create,create view,show view,execute,index on rulian.* to ljf@'%' identified by '123456';
注:一是全部操作授权,一是针对性操作授权。

 

(7)移除授权;
Mysql> revoke all on rulian.* from 'ljf'@'%';

(8)刷新授权表;
Mysql> flush privileges;
注:用于配置即时生效。

 

(9)退出
Mysql> exit;

 

posted @ 2019-07-16 15:30  月下麦田  阅读(2140)  评论(0编辑  收藏  举报