Home Database Mysql Tutorial MySQL 权限分配_MySQL

MySQL 权限分配_MySQL

Jun 01, 2016 pm 01:50 PM
concept Certification

bitsCN.com

     MySQL的权限系统围绕着两个概念:

1:认证->确定用户是否允许连接数据库服务器

2:授权->确定用户是否拥有足够的权限执行查询请求等。

显然从上面可知,如果认证不成功的话,哪么授权肯定是无法进行的。在这里我们要关注两个表,分别是在MySQL数据库中user表和db表。

user表在某种程度上是独一无二的,因为它是唯一一个在权限请求的认证和授权阶段都起作用的表,也是唯一一个存数MySQL服务器相关权限的权限表。在认证阶段,它只是负责为用户授权访问MySQL服务器,确定用户每小时的最大连接数和最大并发数;在授权阶段,user确定允许访问服务器的用户是否被赋予了操作数据库的全局权限,确定用户每小时的最大查询数和更新数。

db表用于为每个用户针对每个数据库赋予权限。具体的可以查看db的字段。

用户和权限管理命令:

create user :用于创建新的用户账户(从5.0版本开始有这个命令),在创建这个用户的时候不分配任何权限,需要在创建之后通过grant命令来给改用户分配相应的权限。

eg:create user guest@localhost identified by '123456';
grant select on mydb.* to guest@localhost;

drop user:删除一个用户账户(注意在4.1.1版本之前只能删除没有任何权限的账户,5.0.2之后可以删除任何账户)

eg:drop user guest;

rename user:可以实现重命名一个用户账号。

grant:用于管理访问权限,也就是给用户账号授权。当然它同样可以创建一个新的用户账户。

eg:grant select, insert, update, delete on new_db.* to guest@'%' identified by '88888888';

grant 权限 on 数据库.表 to 用户 @ 访问方式 identified by 密码

grant select on mydb.* to guest@localhost identified by '123456';

BTW:如果需要一个空密码或者无密码的账户,必须先用Create User命令,然后通过

grant来分配权限。如果如下操作:

grant all privileges on mydb.* to visitor@'%' ;而在数据库user表中没有先创建visitor

用户,则会发生1133错误"Can't find any matching row in the user table"。grant只能创

有密码的账户。

revoke:删除一个账户,具体查看MySQL的文档。

 

bitsCN.com
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 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)

1.1.1.1 How to log in to the online authentication system 1.1.1.1 How to log in to the online authentication system Apr 20, 2023 am 10:44 AM

1.1.1.1 Login method for the Internet authentication system: 1. Search for the campus network wireless signal and connect; 2. Open the browser and select "Self-Service" on the pop-up authentication interface; 3. Enter the user name and initial password to log in; 4. Complete Personal information and set a strong password.

How to use ThinkPHP6 for JWT authentication? How to use ThinkPHP6 for JWT authentication? Jun 12, 2023 pm 12:18 PM

JWT (JSONWebToken) is a lightweight authentication and authorization mechanism that uses JSON objects as security tokens to securely transmit user identity information between multiple systems. ThinkPHP6 is an efficient and flexible MVC framework based on PHP language. It provides many useful tools and functions, including JWT authentication mechanism. In this article, we will introduce how to use ThinkPHP6 for JWT authentication to ensure the security and reliability of web applications

What does the metaverse concept mean? What is the metaverse concept? What does the metaverse concept mean? What is the metaverse concept? Feb 22, 2024 pm 03:55 PM

The Metaverse is an illusory world that uses technology to map and interact with the real world. Analysis 1 Metaverse [Metaverse] is an illusory world that makes full use of technological methods to link and create, and maps and interacts with the real world. It is a data living space with the latest social development system. The 2-dimensional universe is essentially a virtual technology and digital process of the real world, which requires a lot of transformation of content production, economic system, customer experience and physical world content. 3 However, the development trend of the metaverse is gradual. It is finally formed by the continuous combination and evolution of many tools and platforms with the support of shared infrastructure, standards and protocols. Supplement: What is the metaverse composed of? 1 The metaverse is composed of Meta and Verse, Meta is transcendence, and V

What are the differences between WeChat official account certification and non-certification? What are the differences between WeChat official account certification and non-certification? Sep 19, 2023 pm 02:15 PM

The difference between WeChat public account authentication and non-authentication lies in the authentication logo, function permissions, push frequency, interface permissions and user trust. Detailed introduction: 1. Certification logo. Certified public accounts will obtain the official certification logo, which is the blue V logo. This logo can increase the credibility and authority of the public account and make it easier for users to identify the real official public account; 2. Function permissions. Certified public accounts have more functions and permissions than uncertified public accounts. For example, certified public accounts can apply to activate the WeChat payment function to achieve online payment and commercial operations, etc.

Master the key concepts of Spring MVC: Understand these important features Master the key concepts of Spring MVC: Understand these important features Dec 29, 2023 am 09:14 AM

Understand the key features of SpringMVC: To master these important concepts, specific code examples are required. SpringMVC is a Java-based web application development framework that helps developers build flexible and scalable structures through the Model-View-Controller (MVC) architectural pattern. web application. Understanding and mastering the key features of SpringMVC will enable us to develop and manage our web applications more efficiently. This article will introduce some important concepts of SpringMVC

Learn more about Gunicorn's fundamentals and features Learn more about Gunicorn's fundamentals and features Jan 03, 2024 am 08:41 AM

Basic concepts and functions of Gunicorn Gunicorn is a tool for running WSGI servers in Python web applications. WSGI (Web Server Gateway Interface) is a specification defined by the Python language and is used to define the communication interface between web servers and web applications. Gunicorn enables Python web applications to be deployed and run in production environments by implementing the WSGI specification. The function of Gunicorn is to

Introduction and core concepts of Oracle RAC Introduction and core concepts of Oracle RAC Mar 07, 2024 am 11:39 AM

Introduction and core concepts of OracleRAC (RealApplicationClusters) As the amount of enterprise data continues to grow and the demand for high availability and high performance becomes increasingly prominent, database cluster technology becomes more and more important. OracleRAC (RealApplicationClusters) is designed to solve this problem. OracleRAC is a high-availability, high-performance cluster database solution launched by Oracle.

What is kc certification? What is kc certification? Oct 11, 2022 pm 03:20 PM

KC certification is to enable consumers to more clearly understand the certification mark marked on the products they purchase. It is a national unified certification mark that is used to reduce the various certification fees borne by product manufacturers. The Korea Institute of Technical Standards (KATS) announced on August 20, 2008 that it would implement KC certification from July 2009 to December 2010.

See all articles