search
HomeBackend DevelopmentPHP TutorialRelated management analysis of MySQL database account authorization (1)_PHP tutorial

Related management analysis of MySQL database account authorization (1)_PHP tutorial

Jul 13, 2016 pm 05:03 PM
mysqlWhichhowAuthorizedatabaseuserofRelatedKnowmanageadministratorparseset upaccountAccount

MySQL administrators should know how to set up MySQL user accounts, indicate which users can connect to the server, where to connect from, and what they can do after connecting. MySQL 3.22.11 began to introduce two statements to make this job easier: the GRANT statement creates a MySQL user and specifies its permissions, and the REVOKE statement removes permissions. Two statements act as a front-end to the MySQL database and provide an alternative to directly manipulating the contents of these tables. The CREATE and REVOKE statements affect 4 tables: Authorization table

Contents

user Users who can connect to the server and any global permissions they have

db Database-level permissions

tables_priv Table-level permissions

columns_priv Column-level permissions

There is also a fifth authorization table (host), but it is not affected by GRANT and REVOKE.

When you issue a GRANT statement to a user, a record is created for that user in the user table. If the statement specifies any global permissions (administrative permissions or permissions that apply to all databases), these are also recorded in the user table. If you specify database, table, and column-level permissions, they are recorded in the db, tables_priv, and columns_priv tables respectively.

Using GRANT and REVOKE is easier than modifying the authorization table directly. However, it is recommended that you read the "MySQL Security Guide". These tables are extremely important, and as an administrator, you should understand how they go beyond the functional level of GRANT and REVOKE statements.

In the following chapters, we will introduce how to set up a MySQL user account and authorize it. We also cover how to revoke authority and remove users from the authorization table.

You may also want to consider using the mysqlAccess and mysql_setpermission scripts, which are part of the MySQL distribution. They are Perl scripts that provide an alternative to the GRANT statement for setting user accounts. mysql_setpermission requires DBI support to be installed.

1. Create a user and authorize

The syntax of the GRANT statement looks like this:

GRANT privileges (columns) ON what TO user IDENTIFIED BY "password" WITH GRANT OPTION

To use this statement, you need to fill in the following sections:

privileges

Privileges granted to the user, the following table lists the privileges available for the GRANT statement Permission specifier:

Permission specifier

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630983.htmlTechArticleMySQL administrator should know how to set up a MySQL user account, indicate which user can connect to the server, where to connect, and after connecting What can be done. MySQL 3.22.11 began to introduce two statements to make...
Statement
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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

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

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.