|
此文章由 windix 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 windix 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 Limitless 于 2011-8-22 22:45 发表 ![](http://www.oursteps.com.au/bbs/images/common/back.gif)
mysql 有内建function可以读取写入文件,你用root登录就是root权限,/etc/shadow随便看随便改
mysql的root用户不等同于系统的root用户。当然如果你没有好习惯,平时使用你的机器就是用root account的话那就当我没说。
确实 "LOAD DATA" 命令可以从系统读文件,但是读的都是普通用户可以读的文件。你给的例子很好,我确实去试了一下:
首先,/etc/shadow 确实是只有root用户才能读的:- $ cat /etc/shadow
- cat: /etc/shadow: Permission denied
复制代码 下面我用mysql root用户登入,来读下文件:- $ mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 6385
- Server version: 5.1.54-1ubuntu4 (Ubuntu)
- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- This software comes with ABSOLUTELY NO WARRANTY. This is free software,
- and you are welcome to modify and redistribute it under the GPL v2 license
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> use test;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
- mysql> LOAD DATA INFILE '/etc/passwd' INTO TABLE test;
- Query OK, 38 rows affected (0.01 sec)
- Records: 38 Deleted: 0 Skipped: 0 Warnings: 0
- mysql> LOAD DATA INFILE '/etc/shadow' INTO TABLE test;
- ERROR 1085 (HY000): The file '/etc/shadow' must be in the database directory or be readable by all
- mysql>
复制代码 你可以看到,/etc/passwd是随便读的,但是/etc/shadow确读不出来。
mysql一般使用的都是系统中的mysql用户,不管mysql中登录进的用户是什么。你的混淆可能在于,如果命令行上面不给出用户(-u username),系统会默认发送当前用户给mysql. |
|