The GRANT statement can be used in mysql to add permissions to users. The syntax is "GRANT permission type ON permission level value TO user [IDENTIFIED BY 'password'] [WITH clause];"; where the parameter "user" represents the user account , the format is "'username'@'hostname'".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In MySQL, you can use the GRANT statement to authorize users and increase their permissions.
The syntax format is as follows:
GRANT priv_type [(column_list)] ON database.table TO user [IDENTIFIED BY 'password'] [WITH with_option [with_option]...]
Among them:
priv_type parameter indicates the permission type;
The columns_list parameter indicates which columns the permissions apply to. When this parameter is omitted, it means it applies to the entire table;
database.table is used to specify the level of permissions;
The user parameter represents the user account, which is composed of user name and host name. The format is "'username'@'hostname'";
IDENTIFIED BY parameter is used to set the user name Password;
# The password parameter is the user's new password.
The permissions that can be granted in MySQL are as follows:
Column permissions are related to a specific column in the table. For example, you can use the UPDATE statement to update permissions on the value of the name column in the students table.
Table permissions are related to all data in a specific table. For example, you can use the SELECT statement to query the permissions for all data in the students table.
Database permissions are related to all tables in a specific database. For example, you can create new tables in the existing database mytest.
User permissions are related to all databases in MySQL. For example, you can delete an existing database or create a new database.
Correspondingly, the values that can be used to specify the permission level in the GRANT statement have the following formats:
*: indicates the current database of all tables.
*.*: Indicates all tables in all databases.
db_name.*: Indicates all tables in a database, db_name specifies the database name.
db_name.tbl_name: Represents a table or view in a database, db_name specifies the database name, tbl_name specifies the table name or view name.
db_name.routine_name: Represents a stored procedure or function in a database, routine_name specifies the stored procedure name or function name.
TO clause: If permission is granted to a user that does not exist, MySQL will automatically execute a CREATE USER statement to create the user, but a password must be set for the user.
In MySQL, only users with GRANT permissions can execute GRANT statements.
Example:
Use the GRANT statement to create a new user testUser with the password testPwd. User testUser has query and insert permissions on all data, and is granted GRANT permissions.
mysql> GRANT SELECT,INSERT ON *.* -> TO 'testUser'@'localhost' -> IDENTIFIED BY 'testPwd' -> WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.05 sec)
Use the SHOW GRANTS statement to query the permissions of user testUser, as shown below.
Extended knowledge: Permission type description
1) When granting database permissions, the
Permission name | corresponds to the field in the user table | Description |
---|---|---|
SELECT | Select_priv | means granting the user permission to use the SELECT statement to access all tables and views in a specific database. |
INSERT | Insert_priv | Indicates that the user is granted permission to use the INSERT statement to add data rows to all tables in a specific database. |
DELETE | Delete_priv | Indicates that the user is granted permission to use the DELETE statement to delete data rows from all tables in a specific database. |
UPDATE | Update_priv | means granting the user permission to use the UPDATE statement to update the values of all data tables in a specific database. |
REFERENCES | References_priv | indicates that the user is granted permission to create foreign keys pointing to tables in a specific database. |
CREATE | Create_priv | Represents the authority that authorizes a user to create a new table in a specific database using the CREATE TABLE statement. |
ALTER | Alter_priv | Indicates that the user is granted permission to use the ALTER TABLE statement to modify all data tables in a specific database. |
SHOW VIEW | Show_view_priv | Indicates that the user is granted permission to view the view definitions of existing views in a specific database. |
CREATE ROUTINE | Create_routine_priv | means granting the user permission to create stored procedures and stored functions for a specific database. |
ALTER ROUTINE | Alter_routine_priv | indicates that the user is granted permission to update and delete existing stored procedures and stored functions in the database. |
INDEX | Index_priv | indicates that the user is granted permission to define and delete indexes on all data tables in a specific database. |
DROP | Drop_priv | means granting the user permission to delete all tables and views in a specific database. |
CREATE TEMPORARY TABLES | Create_tmp_table_priv | Indicates that the user is granted permission to create temporary tables in a specific database. |
CREATE VIEW | Create_view_priv | means granting the user permission to create new views in a specific database. |
EXECUTE ROUTINE | Execute_priv | means granting the user permission to call stored procedures and stored functions of a specific database. |
LOCK TABLES | Lock_tables_priv | indicates that the user is granted permission to lock existing data tables of a specific database. |
ALL or ALL PRIVILEGES or SUPER | Super_priv | means all the above permissions/super permissions |
2) When granting table permissions,
Permission name | corresponds to the user table Field | Description |
---|---|---|
SELECT | Select_priv | Grants users permission to access specific tables using the SELECT statement |
INSERT | Insert_priv | Grants the user permission to add rows to a specific table using the INSERT statement |
DELETE | Delete_priv | Grants the user permission to delete data rows from a specific table using the DELETE statement |
DROP | Drop_priv | Grant users the permission to delete data tables |
UPDATE | Update_priv | Grant users the permission to update specific data tables using the UPDATE statement Permissions |
ALTER | Alter_priv | Grants users permission to use the ALTER TABLE statement to modify the data table |
REFERENCES | References_priv | Grants the user permission to create a foreign key to reference a specific data table |
CREATE | Create_priv | Grants the user permission to create a data table using a specific name |
INDEX | Index_priv | Grants the user the permission to create a data table in the table Permissions defined on the index |
ALL or ALL PRIVILEGES or SUPER | Super_priv | All permission names |
3) When granting column permissions, the value of
4) The most efficient permission is user permission.
When granting user permissions, the
- ## CREATE USER: Indicates that the user is granted permission to create and delete new users.
- SHOW DATABASES: Indicates that the user is granted permission to use the SHOW DATABASES statement to view the definitions of all existing databases.
mysql video tutorial]
The above is the detailed content of How to increase permissions in mysql. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
