User who created the Mysql database
Note: the SQL statement ends with ";" by default in the Mysql database. When entering commands, keywords can be uppercase or lowercase, but must be consistent, I prefer to use lowercase, personal habit.
There are three main ways to create database users in Mysql:
1 by inserting data records into the user table of the mysql library (Note: mysql users are saved in the user table by default):
Mysql > insert into user (name,passwd) values ('zwj','abcdefg')
Description:
Insert into: keyword
User: table name, followed by field name in parentheses
Values: keyword followed by the value of the field in parentheses
After you have created a user, you can view the established user: mysql > select * from mysql.user
In general, it is not recommended to create users in the above way (too amateur)
2 use the create user statement to create a user:
Mysql > create user't 100 million dollars 127.0.0.1 'identified by't 100
Description:
Create user: keyword
T100: user name
127.0.0.1: source address, which represents the local machine, or can be written as a network segment such as 192.168.10.%
Identified by: the keyword used to set the password. If omitted, the password is empty.
After the user is established, authorization is required, otherwise most operations will not be possible except to connect to the database.
3 use the grant statement to create a user and grant permissions:
Mysql > grant select on mysql.* to 't100' identified by 't100'
Description:
Grant: keyword
Select: permissions for query
On: keyword
All tables under the mysql.*:mysql library. * is a wildcard that represents all.
The above statement means: create a user t110 that allows the client from 192.168.10.1 to access this database and grant the right to query.
Users need to refresh the permission table after they are built:
Mysql > flush privileges
View permission: mysql > show grants for 't100 requests permission 192.168.10.1'
Revoke permissions: mysql > revoke select on mysql.* from 't100 revoked permissions 192.168.10.1'
The third way is the more common way of creating users and authorizations.