MySQL file权限
发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,file权限指的是是否能够对系统的文件读取和写操作. 拥有file权限才可以执行 select ..into outfile和load data
千家信息网最后更新 2025年01月22日MySQL file权限
1、创建环境 mysql> CREATE USER 'filetest'@'localhost' IDENTIFIED BY 'mypass'; Query OK, 0 rows affected (0.01 sec)
mysql> GRANT select ON test.* TO 'filetest'@'localhost'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> GRANT select ON test.* TO 'filetest'@'localhost'; Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE tab1( -> aa varchar(50), -> bb varchar(50) -> ); Query OK, 0 rows affected (0.02 sec)
mysql> mysql> insert into tab1 values('aaa','bbb'); Query OK, 1 row affected (0.01 sec)
mysql> insert into tab1 values('ccc','ddd'); Query OK, 1 row affected (0.01 sec)
mysql>
2、切换到filetest用户: [root@master ~]# mysql -ufiletest -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.13-log Source distribution
Copyright (c) 2000, 2015, 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> 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec)
mysql> select * from tab1 into outfile '/mysql/mysql57/st_file1'; ERROR 1045 (28000): Access denied for user 'filetest'@'localhost' (using password: YES) 没有file权限,倒出报错!
3、root登陆授权: mysql> grant file on test.* to filetest@localhost; ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES mysql> grant file on *.* to filetest@localhost; Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
4、filetest用户登陆
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> select * from tab1 into outfile '/mysql/mysql57/st_file'; Query OK, 2 rows affected (0.01 sec)
mysql> [root@master mysql57]# cat st_file aaa bbb ccc ddd
5、导入 mysql> create table tab2 as select * from tab1; Query OK, 2 rows affected (0.02 sec) Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tab2 -> ; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | aa | varchar(50) | YES | | NULL | | | bb | varchar(50) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.01 sec)
mysql> select * from tab2; +------+------+ | aa | bb | +------+------+ | aaa | bbb | | ccc | ddd | +------+------+ 2 rows in set (0.00 sec)
mysql> truncate table tab2; Query OK, 0 rows affected (0.02 sec)
mysql> select * from tab2; Empty set (0.00 sec)
mysql> load data infile '/mysql/mysql57/st_file1' into table tab2; ERROR 1142 (42000): INSERT command denied to user 'filetest'@'localhost' for table 'tab2'
##root登陆授权: mysql> grant insert on test.* to filetest@localhost; Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
##重新登陆: mysql> load data infile '/mysql/mysql57/st_file1' into table tab2; Query OK, 2 rows affected (0.01 sec) Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select * from tab2; +------+------+ | aa | bb | +------+------+ | aaa | bbb | | ccc | ddd | +------+------+ 2 rows in set (0.00 sec)
小实验完成。
file权限指的是是否能够对系统的文件读取和写操作.
拥有file权限才可以执行 select ..into outfile和load data infile…操作,但是不要把file, process, super权限授予管理员以外的账号,这样存在严重的安全隐患。 下面简单做个试验:
1、创建环境 mysql> CREATE USER 'filetest'@'localhost' IDENTIFIED BY 'mypass'; Query OK, 0 rows affected (0.01 sec)
mysql> GRANT select ON test.* TO 'filetest'@'localhost'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> GRANT select ON test.* TO 'filetest'@'localhost'; Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE tab1( -> aa varchar(50), -> bb varchar(50) -> ); Query OK, 0 rows affected (0.02 sec)
mysql> mysql> insert into tab1 values('aaa','bbb'); Query OK, 1 row affected (0.01 sec)
mysql> insert into tab1 values('ccc','ddd'); Query OK, 1 row affected (0.01 sec)
mysql>
2、切换到filetest用户: [root@master ~]# mysql -ufiletest -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.13-log Source distribution
Copyright (c) 2000, 2015, 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> 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec)
mysql> select * from tab1 into outfile '/mysql/mysql57/st_file1'; ERROR 1045 (28000): Access denied for user 'filetest'@'localhost' (using password: YES) 没有file权限,倒出报错!
3、root登陆授权: mysql> grant file on test.* to filetest@localhost; ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES mysql> grant file on *.* to filetest@localhost; Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
4、filetest用户登陆
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> select * from tab1 into outfile '/mysql/mysql57/st_file'; Query OK, 2 rows affected (0.01 sec)
mysql> [root@master mysql57]# cat st_file aaa bbb ccc ddd
5、导入 mysql> create table tab2 as select * from tab1; Query OK, 2 rows affected (0.02 sec) Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tab2 -> ; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | aa | varchar(50) | YES | | NULL | | | bb | varchar(50) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.01 sec)
mysql> select * from tab2; +------+------+ | aa | bb | +------+------+ | aaa | bbb | | ccc | ddd | +------+------+ 2 rows in set (0.00 sec)
mysql> truncate table tab2; Query OK, 0 rows affected (0.02 sec)
mysql> select * from tab2; Empty set (0.00 sec)
mysql> load data infile '/mysql/mysql57/st_file1' into table tab2; ERROR 1142 (42000): INSERT command denied to user 'filetest'@'localhost' for table 'tab2'
##root登陆授权: mysql> grant insert on test.* to filetest@localhost; Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
##重新登陆: mysql> load data infile '/mysql/mysql57/st_file1' into table tab2; Query OK, 2 rows affected (0.01 sec) Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select * from tab2; +------+------+ | aa | bb | +------+------+ | aaa | bbb | | ccc | ddd | +------+------+ 2 rows in set (0.00 sec)
小实验完成。
权限
登陆
用户
安全
文件
环境
管理员
系统
账号
隐患
切换
实验
管理
试验
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怎么评估需要多大的服务器
查看英语等级考试视频的数据库
湖北网络安全工程资质
网络安全面临的威胁主要有哪五种
加强网络安全防护管理
医疗行业大数据服务器
互联网金融发展 金融科技
工商银行软件开发实习工资
ibm服务器进安全模式
姜堰区网络技术价格表格
服务器运行速度为什么快
越南服务器工作原理
数字科技和互联网是不同的路
最新数据库技术与应用
服务器做磁盘阵列
orcal数据库在哪下载
数据库中的雇员
下载服务器1g带宽
上门剪发软件开发定制
与数据库中的语句计算相似性
网络安全法律法规宣传画
ncbi四个数据库
朝阳区品牌软件开发
现场总线主从站还是服务器客户端
流行网络技术的词语
速达sql数据库启动不了
东莞汽车备件管理软件开发
金山区本地软件开发诚信合作
棋牌服务器一个g能带多少
mdf文件还原数据库