常飛·梦 发表于 2013-3-26 11:52:57

关于mysql用户权限问题

刚刚接触mysql,在看了书之后,对于权限有一个问题。
在新建了一个用户后,没有赋予任何权限,但是这个用户为什么就能查询其它数据库的表数据呢?
还是我理解有问题呢?

--创建新用户
# mysql -uroot -proot
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create user lcz@localhost identified by 'lcz';
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for lcz@localhost;
+------------------------------------------------------------------------------------------------------------+
| Grants for lcz@localhost                                                                                 |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'lcz'@'localhost' IDENTIFIED BY PASSWORD '*A1238F347489C1C8313C8BC039B6C6B1E00A6640' |
+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> exit
Bye

--用新用户登录
# mysql -ulcz -plcz
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.5.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
--此时就能查到其它数据库表数据
mysql> select count(1) from sqoop.tb1;
+----------+
| count(1) |
+----------+
|       93 |
+----------+
1 row in set (0.00 sec)
mysql> create table test.t1 as select * from sqoop.tb1;
Query OK, 93 rows affected (0.16 sec)
Records: 93Duplicates: 0Warnings: 0

kider 发表于 2013-3-26 17:23:34

应该是你弄错了。还奇怪呢,我这里还试了试,没有问题。
mysql -ulcz -plcz进入后用shou grants 看看权限。如果还是USAGE,那么就什么都不能做。

可以在用show databases; show tables;命令试试...
页: [1]
查看完整版本: 关于mysql用户权限问题