Mysql to create users and ssc website Construction
There are three ways for mysql to create users: ssc website construction [enterprise E: 1793], INSERT USER table method, CREATE USER method, GRANT method.
1. Create a user through the CREATE USER command
Script: CREATE USER 'username'@'host' [IDENTIFIED BY' PASSWORD'] where the password is optional
Example: CREATE USER 'test'@'127.0.0.1' IDENTIFIED BY "123"
CREATE USER 'test'@'127.0.0.%' IDENTIFIED BY "123"
CREATE USER 'test'@'%'
Description: the user created by this method only has the right to connect to the database and needs to be authorized later.
2. Create a user through the GRANT command
Personal habits generally use this method to create users. When there is a user in the database, GRANT will authorize the user, but when the user does not exist in the database, it will create
The corresponding user is authorized. (indicating that the above step is superfluous)
Script:
GRANT ON [object] [IDENTIFIED BY 'password']
[WITH GRANT OPTION]
MAX_QUERIES_PER_HOUR count
MAX_UPDATES_PER_HOUR count
MAX_CONNECTIONS_PER_HOUR count
MAX_USER_CONNECTIONS count
Description: priv stands for permissions, select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file and other 14 permissions
Example: mysql > grant select,insert,update,delete,create,drop on test.hr to test@127.0.0.1 identified by '123'
Description: assign the user test whose host is 127.0.0.1 to select,insert,update,delete,create,drop and other operations on the hr table of the database test, and set the password
It's 123.
Mysql > grant all privileges on test. To test@127.0.0.1 identified by '123'
Note: assign the user test with host 127.0.0.1 to perform all operations on all tables in the database test, and set the password to 123.
Mysql > grant all privileges on. To test@127.0.0.1 identified by '123'
Note: assign the user test with host 127.0.0.1 to perform all operations on all tables in all databases, and set the password to 123.
Mysql > grant all privileges on. * to test@127.0.0.1 identified by '123'
Description: user test assigns permissions to perform all operations on all tables in all databases and sets the password to 123.