1. Create a new user
@>mysql-u root-p
@> Password
Create user
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES (' localhost ', ' JEECN ', Password (' JEECN '));
Refresh System Permissions Table
Mysql>flush privileges;
This creates a user named: JEECN Password: JEECN.
2. Authorizing the user
//log in to MySQL (with root access). I am logged in as root.
@>mysql-u root-p
@> Password
//First create a database for the user (JEECNDB)
mysql>create database jeecndb;
//Authorize JEECN users to have all rights to the JEECN database
@>grant all privileges in jeecndb.* to [e-mail protected] identified by ' JEECN ';
//Refresh System Permissions Table
Mysql>flush privileges;
mysql> grant Permissions 1, permissions 2,... Permission n on the database name. Table name to User name @ user address identified by ' connection password ';
permissions 1, permissions 2,... Permission n represents 14 permissions, such as Select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file.
When permissions 1, permissions 2,... Permission n is replaced by all privileges or all to give the user full permission.
when the database name. The table name is replaced by *. *, which indicates that the user is given permission to manipulate all tables on the server.
The user address can be localhost, or it can be an IP address, a machine name, and a domain name. You can also use '% ' to indicate connections from any address.
' connection password ' cannot be empty, otherwise the creation failed.
For example:
mysql>grant Select,insert,update,delete,create,drop on Vtdc.employee to [e-mail protected] identified by ' 123′;
the user Jee from 10.163.225.87 is assigned the ability to perform operations such as Select,insert,update,delete,create,drop on the employee table of the database VTDC, and set the password to 123.
mysql>grant all privileges in vtdc.* to [e-mail protected] identified by ' 123′;
the user Jee from 10.163.225.87 is assigned permission to perform all operations on the database VTDC all tables, and the password is set to 123.
mysql>grant All privileges on * * to [e-mail protected] identified by ' 123′;
the user Jee from 10.163.225.87 is assigned permission to perform all operations on all tables in all databases, and the password is set to 123.
mysql>grant All privileges on * * to [e-mail protected] identified by ' 123′;
the native user Jee is assigned permission to perform all operations on all tables in all databases, and the password is set to 123.
3. Delete a user
@>mysql-u root-p
@> Password
mysql>delete from user WHERE user= "JEECN" and host= "localhost";
Mysql>flush privileges;
//Delete a user's database
mysql>drop database jeecndb;
4. Modify the specified user password
@>mysql-u root-p
@> Password
mysql>update Mysql.user Set Password=password (' New password ') where user= "JEECN" and host= "localhost";
Mysql>flush privileges;
mysql>quit;
MySQL user management and permissions assignment