因为你的授权表中一定还存在有+-----------------+--------------+--------------------
| Host            | User         | Password
+-----------------+--------------+--------------------
| localhost       | ....               
+-----------------+--------------+--------------------这样的用户信息,当你以 mysql -h localhost -u root 登录时,
它先匹配的是这个用户授权信息,
而不是
Host = % User = tsm

解决方案 »

  1.   

    顺便问一下,我已经授予某个用户特定数据库的grant权利,但该用户不能把特定数据库的权限给别的用户,为什么?
      

  2.   

    呵呵,
    一定是你的操作上有问题了,看我的操作全过程
    Microsoft Windows 2000 [Version 5.00.2195]
    (C) 版权所有 1985-2000 Microsoft Corp.================= 此处开始以 root 身份登录C:\>mysql -h localhost -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2 to server version: 4.0.13-nt-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.================= 此处建立一个对 test 库有所有权限(包括GRANT)的用户 WXQmysql> GRANT ALL ON test.* TO WXQ@'localhost' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)================= 此处建立一个对 test 库只有SELECT权限的用户 WXQ2mysql> GRANT SELECT ON test.* TO WXQ2@'localhost';
    Query OK, 0 rows affected (0.00 sec)================= 此处验证用户建立是否成功mysql> SELECT Host,Db,User,Select_priv AS S,Insert_priv AS I,Update_priv AS U
        -> FROM mysql.db;
    +-----------+------+------+---+---+---+
    | Host      | Db   | User | S | I | U |
    +-----------+------+------+---+---+---+
    | localhost | test | WXQ  | Y | Y | Y |
    | localhost | test | WXQ2 | Y | N | N |
    +-----------+------+------+---+---+---+
    2 rows in set (0.00 sec)================= 此处退出连接,然后以用户 WXQ 登录mysql> exit
    ByeC:\>mysql -h localhost -u WXQ
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 13 to server version: 4.0.13-nt-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.================= 此处验证当前连接用户的身份mysql> SELECT USER();
    +---------------+
    | USER()        |
    +---------------+
    | WXQ@localhost |
    +---------------+
    1 row in set (0.00 sec)================= 此处将 WXQ 对 test 库的所有权限授权给 WXQ2 (除 GRANT)mysql> GRANT ALL ON test.* TO WXQ2@'localhost';
    Query OK, 0 rows affected (0.00 sec)================= 此处退出连接,然后以用户 root 登录,这是为了查看 mysql.db 表信息mysql> exit;
    ByeC:\>mysql -h localhost -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 15 to server version: 4.0.13-nt-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SELECT Host,Db,User,Select_priv AS S,Insert_priv AS I,Update_priv AS U
        -> FROM mysql.db;
    +-----------+------+------+---+---+---+
    | Host      | Db   | User | S | I | U |
    +-----------+------+------+---+---+---+
    | localhost | test | WXQ  | Y | Y | Y |
    | localhost | test | WXQ2 | Y | Y | Y |
    +-----------+------+------+---+---+---+
    2 rows in set (0.00 sec)mysql>