标签:style blog http io ar os 使用 sp for
1.mysql数据库表结构
1)mysql数据库的所有表:
2)user表的结构
3)db表结构
4)权限表(tables_priv和columns_priv表)
①tables_priv表结构:
②columns_priv表结构:
6)procs_priv表结构
2.账户管理
1)使用命令行命令登入mysql
2)新增用户
①使用grant user语句新增用户
②使用insert语句添加用户
③使用GRANT语句新建普通用户
3)删除用户
①使用drop user语句删除用户
②使用delete语句删除用户
4)root修改自己的密码
①使用mysqladmin工具更改密码(注:密码一定要用双引号括起来)
②使用update语句更改user表
③使用set命令更改密码
5)root用户修改普通用户的密码
①用set命令修改密码

(修改密码为yunshu,密码要用双引号括起来,用单引号会出问题
②使用update语句更改user表

(更改密码为password
③使用grant语句更改密码

(将yunshu的密码更改为sercet
6)普通用户修改自己的密码
①使用set语句修改
②使用mysqladmin工具修改密码

(密码yunshu后面不能带分号,否则会将分号当作密码
7)root用户密码丢失的解决方法
①使用--skip-grant-tables选项启动MySQL服务
windows:
mysqld --skip-grant-tables
mysqld-nt --skip-grant-tables
net start mysql --skip-grant-tables
linux:
mysqld_safe --skip-grant-tables user=mysql
/etc/init.d/mysql start --mysqld --skip-grant-tables
②用update语句修改密码,加载权限表
例子:

(登入mysql,此时不用密码可登入

(不能用set语句修改密码

(用update语句修改密码,并用flush privileges加载权限表

(再次登录,OK!
3、权限管理
1)user表的权限列
2)授权
语法:
GRANT priv_type [(column_list)] ON database.table TO user [IDENTIFIED BY [PASSWORD] ‘password‘] [,user [IDDENTIFIED BY [PASSWORD] ‘password‘]]...[WITH with_option [with_option]...]
with_option参数:
a、GRANT OPTION:被授权的用户可以将这些权限赋予给别的用户;
b、MAX_QUERIES_PER_HOUR_count:设置每个小时可以执行count次查询;
c、MAX_UPDATES_PER_HOUR_count:设置每个小时可以执行count次更新;
d、MAX_CONNECTIONS_PER_HOUR_count:设置每个小时可以建立count次连接;
e、MAX_USER_CONNECTIONS_PER_count:设置单个用户可以同时具有的count连接数;
例子:

(给yunshu用户授权

(用yunshu用户给yunshu2用户授权
3)收回权限
收回指定权限的REVOKE语句的基本语法是:
REVOKE priv_type [(column_list)]... ON database.table FROM user [,user]...
收回全部权限的REVOKE语句的基本语法是:
REVOKE ALL PRIVILEGES,GRANT OPTION FROM user [,user]...
例子:
4)查看用户权限
①查看user表
②使用show grant语句
基本语法:SHOW GRANTS FOR ‘username‘@‘hostname‘
例子:
MySQL用户管理
标签:style blog http io ar os 使用 sp for
原文地址:http://www.cnblogs.com/luoyunshu/p/4160530.html