常见命令操作以 root 用户为示例。
登入sql
- mysql -u root -p
刷新权限(每次修改权限需要执行刷新权限)
- flush privileges;
查询用户本地权限
- select * from mysql.user where User='root' and Host='localhost'\G;
查询用户所有权限
- select * from mysql.user where User='root' and Host='%'\G;
赋予用户所有权限
- update mysql.user set Grant_priv='Y' where User='root' and Host='%';
赋予某个权限给用户
- update user set Grant_priv ='Y' where user = 'root';
更新用户密码
- update mysql.user set password=PASSWORD('123456') where User='root';
- update user set password=password("123456") where user="root";