我想在mysql下新建一个用户,让他只拥有如下权限
1只能查看和管理testdb库
2不能进行删除表,库,表内容
3限制器登录地点为localhost代码应该怎么写?
最好能详细介绍些,谢谢大侠们了

解决方案 »

  1.   

    create user feng11@localhost IDENTIFIED BY  '1234';
    grant select on testdb.* to feng11@localhost;
      

  2.   

    不明白的地方参考一 下MYSQL手册中的语法说明。MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  3.   

    mysql> grant select on foo.* to foo2@localhost identified by '1234';
    Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
      

  4.   


    create database testdb;
    -- 先赋予用户对testdb库下所有权限,然后一个个移出楼主禁止其操作的权限-- 建用户的时候赋予权限,用户名为feng,密码123456,只能以localhost的主机登录。
    grant all on testdb.* to 'feng'@'localhost' identified by '123456';-- 移去删除表、库的权限
    revoke drop on testdb.* from   'feng'@'localhost' ;
    -- 移去删除表数据的权限
    revoke delete on testdb.* from   'feng'@'localhost' ;-- 有一点疑问,楼主的查看和管理,一般的管理,我理解为对数据库的所有操作,
    -- 后面楼主禁止删除,我就移去这2项功能,不知道我的理解对不对,不对的地方楼主再说出来,反正建用户赋予权限,收回权限的例子如上所示。
      

  5.   

    create database testdb;-- 先赋予用户对testdb库下所有权限,然后一个个移出楼主禁止其操作的权限-- 建用户的时候赋予权限,用户名为feng,密码123456,只能以localhost的主机登录。
    grant all on testdb.* to 'feng'@'localhost' identified by '123456';-- 移去删除表、库的权限
    revoke drop on testdb.* from   'feng'@'localhost' ;
    -- 移去删除表数据的权限
    revoke delete on testdb.* from   'feng'@'localhost' ;-- 有一点疑问,楼主的查看和管理,一般的管理,我理解为对数据库的所有操作,
    -- 后面楼主禁止删除,我就移去这2项功能,不知道我的理解对不对,不对的地方楼主再说出来,
    -- 反正建用户赋予权限,收回权限的例子如上所示。
      

  6.   


    grant select on testdb.* username@localhost identified by 'password';
    上面是是建立username帐号,密码为password,只可以查看testdb库下面所有表的信息;
    不知道楼主的管理 是需要那些?