This article mainly introduces mysql related information about creating local users and granting database permissions. The introduction in the article is very detailed. I believe it has certain reference value for everyone. Friends who need it can join us below. Let's see.
Preface
When you install mysql, you usually generate a super user root. Many people continue to use this user. Although this It would be convenient, but superuser privileges are too great and using it everywhere is usually a security risk.
This is similar to the operating system's User management. Most people just use the administrator or root user directly for convenience, which is actually not recommended.
So, how to create a user other than root in mysql and grant corresponding permissions?
Let’s look at an example directly:
CREATE USER ‘golden‘@'localhost' IDENTIFIED BY ‘gd2017‘; GRANT ALL ON myapp.* TO ‘golden‘@'localhost'; FLUSH PRIVILEGES;
Here is a brief analysis of the above statement:
1. create The user statement is used to create a user (and password).
Where golden is the username and gd2017 is the password. localhost indicates a local user.
2. The grant statement is used to empower users.
Among them, all means all permissions, including adding, deleting, modifying and querying data and changing the database; myapp is the name of a specific database, and myapp.* means all tables (and views) under the database ##, etc.); golden is the username just created.
Extension:
Generally, the above settings can meet general needs. For more detailed configuration, you can refer to the mysql official online document ( Version 5.7): https://dev.mysql.com/doc/refman/5.7/en/create-user.htmlhttps://dev.mysql.com/doc /refman/5.7/en/grant.htmlThe above is the detailed content of Parse mysql to create local users and grant database permissions. For more information, please follow other related articles on the PHP Chinese website!