Home Database Mysql Tutorial MySQL安全性指南 (2)(转)_MySQL

MySQL安全性指南 (2)(转)_MySQL

Jun 01, 2016 pm 01:52 PM
safety guide database

  MySQL安全性指南(2)   

  作 者: 晏子

  2.1.3 数据库和表权限

  下列权限运用于数据库和表上的操作。

  ALTER

  允许你使用ALTER TABLE语句,这其实是一个简单的第一级权限,你必须由其他权限,这看你想对数据库实施什么操作。

  CREATE

  允许你创建数据库和表,但不允许创建索引。

  DELETE

  允许你从表中删除现有记录。

  DROP

  允许你删除(抛弃)数据库和表,但不允许删除索引。

  INDEX

  允许你创建并删除索引。

  REFERENCES

  目前不用。

  SELECT

  允许你使用SELECT语句从表中检索数据。对不涉及表的SELECT语句就不必要,如SELECT NOW()或SELECT 4/2。

  UPDATE

  允许你修改表中的已有的记录。

  2.1.4 管理权限

  下列权限运用于控制服务器或用户授权能力的操作的管理性操作。

  FILE

  允许你告诉服务器读或写服务器主机上的文件。该权限不应该随便授予,它很危险,见“回避授权表风险”。服务器确实较谨慎地保持在一定范围内使用该权限。你只能读任何人都能读的文件。你正在写的文件必须不是现存的文件,这防止你迫使服务器重写重要文件,如/etc/passwd或属于别人的数据库的数据目录。

  如果你授权FILE权限,确保你不以UNIX的root用户运行服务器,因为root可在文件系统的任何地方创建新文件。如果你以一个非特权用户运行服务器,服务器只能在给用户能访问的目录中创建文件。

  GRANT

  允许你将你自己的权限授予别人,包括GRANT。

  PROCESS

  允许你通过使用SHOW PROCESS语句或mysqladmin process命令查看服务器内正在运行的线程(进程)的信息。这个权限也允许你用KILL语句或mysqladmin kill命令杀死线程。

你总是能看到或杀死你自己的线程。PROCESS权限赋予你对任何线程做这些事情的能力。

  RELOAD

  允许你执行大量的服务器管理操作。你可以发出FLUSH语句,你也能指性mysqladmin的reload、refresh、flush-hosts、flush-logs、flush-privileges和flush-tables等命令。

  SHUTDOWN

  允许你用mysqladmin shutdown关闭服务器。

  在user、db和host表中,每一个权限以一个单独的列指定。这些列全部声明为一个ENUM("N","Y")类型,所以每个权的缺省值是“N”。在tables_priv和columns_priv中的权限以一个SET表示,它允许权限用一个单个列以任何组合指定。这两个表比其他三个表更新,这就是为什么它们使用更有效的表示方式的原因。(有可能在未来,user、db和host表也用一个SET类型表示。)

  在tables_priv表中的Table_priv列被定义成:

SET('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter')
在coloums_priv表中的Column_priv列被定义成: 

SET('Select','Insert','Update','References')
列权限比表权限少,因为列级较少的权限有意义。例如你能创建一个表,但你不能创建一个孤立的列。

  user表包含某些在其他授权表不存在的权限的列:File_priv、Process_priv、Reload_priv和Shutdown_priv。这些权限运用于你让服务器执行的与任何特定数据库或表不相关的操作。如允许一个用户根据当前数据库是什么来关闭数据库是毫无意义的。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

PHP connections to different databases: MySQL, PostgreSQL, Oracle and more PHP connections to different databases: MySQL, PostgreSQL, Oracle and more Jun 01, 2024 pm 03:02 PM

PHP database connection guide: MySQL: Install the MySQLi extension and create a connection (servername, username, password, dbname). PostgreSQL: Install the PgSQL extension and create a connection (host, dbname, user, password). Oracle: Install the OracleOCI8 extension and create a connection (servername, username, password). Practical case: Obtain MySQL data, PostgreSQL query, OracleOCI8 update record.

How to handle database connections and operations using C++? How to handle database connections and operations using C++? Jun 01, 2024 pm 07:24 PM

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

See all articles