mysql函数为什么需要禁用

mysql函数为什么需要禁用,第1张

主要介绍如下几个方面的设置:

1.load data infile

?View Code MYSQL

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'

[REPLACE | IGNORE]

INTO TABLE tbl_name

[FIELDS

[TERMINATED BY 'string']

[[OPTIONALLY] ENCLOSED BY 'char']

[ESCAPED BY 'char' ]

]

[LINES

[STARTING BY 'string']

[TERMINATED BY 'string']

]

[IGNORE number LINES]

[(col_name_or_user_var,...)]

[SET col_name = expr,...)]

LOAD DATA INFILE语句用于高速地从一个文本文件中读取行,并装入一个表中。

这是一个很危险的内置函数,所以一般建议禁用掉(除非程序有用到本地文件)

通过在my.cnf中设置

1

local-infile=0|1 0表示禁用,1表示开启

2.load_file函数

这个函数和上面的load data 函数类似,都是读取本地文件,对于load_file(filename)函数的使用有如下的条件限制:

读取文件并将这一文件按照字符串的格式返回。 文件的位置必须在服务器上,你必须为文件制定路径全名,而且你还必须拥有FILE 特许权。文件必须可读取,文件容量必须小于 max_allowed_packet字节。

若文件不存在,或因不满足上述条件而不能被读取, 则函数返回值为 NULL。

这个主要通过mysql授权来禁用这个函数,收回用户的file权限

1

revoke file on *.* from 'user'@'IP'//或者不要授予用户的file权限

3.禁用drop命令

1

revoke drop on *.* from 'user'@'IP'

显示:“已经禁用删除数据库(DROP DATABASE)语句”

请教这是在哪里更改设置的? show grants

贴出以供分析,怀疑用的不是 root@localhost 账号。先select user()

然后show grants for 第一步打印出来的用户和host;grant all privileges on *.* to root@'%' identified by "Passwd"!

使用户不具有Create User权限或者deny Create User权限

下面是权限列表

mysql>show privileges \G

*************************** 1. row ***************************

Privilege: Alter

Context: Tables

Comment: To alter the table

*************************** 2. row ***************************

Privilege: Alter routine

Context: Functions,Procedures

Comment: To alter or drop stored functions/procedures

*************************** 3. row ***************************

Privilege: Create

Context: Databases,Tables,Indexes

Comment: To create new databases and tables

*************************** 4. row ***************************

Privilege: Create routine

Context: Databases

Comment: To use CREATE FUNCTION/PROCEDURE

*************************** 5. row ***************************

Privilege: Create temporary tables

Context: Databases

Comment: To use CREATE TEMPORARY TABLE

*************************** 6. row ***************************

Privilege: Create view

Context: Tables

Comment: To create new views

*************************** 7. row ***************************

Privilege: Create user

Context: Server Admin

Comment: To create new users

*************************** 8. row ***************************

Privilege: Delete

Context: Tables

Comment: To delete existing rows

*************************** 9. row ***************************

Privilege: Drop

Context: Databases,Tables

Comment: To drop databases, tables, and views

*************************** 10. row ***************************

Privilege: Event

Context: Server Admin

Comment: To create, alter, drop and execute events

*************************** 11. row ***************************

Privilege: Execute

Context: Functions,Procedures

Comment: To execute stored routines

*************************** 12. row ***************************

Privilege: File

Context: File access on server

Comment: To read and write files on the server

*************************** 13. row ***************************

Privilege: Grant option

Context: Databases,Tables,Functions,Procedures

Comment: To give to other users those privileges you possess

*************************** 14. row ***************************

Privilege: Index

Context: Tables

Comment: To create or drop indexes

*************************** 15. row ***************************

Privilege: Insert

Context: Tables

Comment: To insert data into tables

*************************** 16. row ***************************

Privilege: Lock tables

Context: Databases

Comment: To use LOCK TABLES (together with SELECT privilege)

*************************** 17. row ***************************

Privilege: Process

Context: Server Admin

Comment: To view the plain text of currently executing queries

*************************** 18. row ***************************

Privilege: Proxy

Context: Server Admin

Comment: To make proxy user possible

*************************** 19. row ***************************

Privilege: References

Context: Databases,Tables

Comment: To have references on tables

*************************** 20. row ***************************

Privilege: Reload

Context: Server Admin

Comment: To reload or refresh tables, logs and privileges

*************************** 21. row ***************************

Privilege: Replication client

Context: Server Admin

Comment: To ask where the slave or master servers are

*************************** 22. row ***************************

Privilege: Replication slave

Context: Server Admin

Comment: To read binary log events from the master

*************************** 23. row ***************************

Privilege: Select

Context: Tables

Comment: To retrieve rows from table

*************************** 24. row ***************************

Privilege: Show databases

Context: Server Admin

Comment: To see all databases with SHOW DATABASES

*************************** 25. row ***************************

Privilege: Show view

Context: Tables

Comment: To see views with SHOW CREATE VIEW

*************************** 26. row ***************************

Privilege: Shutdown

Context: Server Admin

Comment: To shut down the server

*************************** 27. row ***************************

Privilege: Super

Context: Server Admin

Comment: To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.

*************************** 28. row ***************************

Privilege: Trigger

Context: Tables

Comment: To use triggers

*************************** 29. row ***************************

Privilege: Create tablespace

Context: Server Admin

Comment: To create/alter/drop tablespaces

*************************** 30. row ***************************

Privilege: Update

Context: Tables

Comment: To update existing rows

*************************** 31. row ***************************

Privilege: Usage

Context: Server Admin

Comment: No privileges - allow connect only

31 rows in set (0.00 sec)

mysql>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8614342.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-18
下一篇 2023-04-18

发表评论

登录后才能评论

评论列表(0条)

保存