数据库安全

1,游客权限:

用root  创建用户:

insert into mysql.user(host,user,password)value('localhost','visit',password('123456'));

登录

重启mysql.

mysql -uvisit -p123456

登录成功

执行命令:

create database gobang;

ERROR 1044 (42000): Access denied for user 'visit'@'localhost' to database 'gobang'

show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+

只能看到两个最基础的数据库。

登录root用户:

create database gobang;

grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';
//刷新系统权限表
mysql>flush privileges;

 然后登录visit用户会看到gobang数据库。

revoke all privileges on phplampDB.* from phplamp@localhost identified by '1234'; 

show databases;

gobang数据库消失。

 

 

posted @ 2014-05-21 15:54  UCanBeFree  阅读(150)  评论(0编辑  收藏  举报