1. new User Login MYSQL @ mysql-uroot-p @ password create user mysqlinsertintomysql. user (Host, User, Password) values ('localhost', jeecn', password ('jeecn'); refresh the system permission table mysqlflushprivileges; then a name is created: jeecn password: jeec
1. create a user // log on to MYSQL @ mysql-u root-p @ password // create a user mysql insert into mysql. user (Host, User, Password) values ('localhost', 'jeecn', password ('jeecn'); // refresh the system permission table mysqlflush privileges; in this way, a password named jeecn is created: jeec
1. Create a user
// Log on to MYSQL
@> Mysql-u root-p
@> Password
// Create a user
Mysql> insert into mysql. user (Host, User, Password) values ('localhost', 'jeecn', password ('jeecn '));
// Refresh the system permission list
Mysql> flush privileges;
In this way, a user named jeecn with the password jeecn is created.
// Log on after exiting
Mysql> exit;
@> Mysql-u jeecn-p
@> Enter the password
Mysql> logon successful
2. Authorize the user
// Log on to MYSQL (with ROOT permission ). I log on as ROOT.
@> Mysql-u root-p
@> Password
// Create a database for the user (jeecnDB)
Mysql> create database jeecnDB;
// Authorize the jeecn user to have all permissions for the jeecn Database
@> Grant all on jeecnDB. * to jeecn @ localhost identified by 'jeecn ';
// Refresh the system permission list
Mysql> flush privileges;
Mysql> other operations
// If you want to assign some permissions to a user, you can write as follows:
Mysql> grant select, update on jeecnDB. * to jeecn @ localhost identified by 'jeecn ';
// Refresh the system permission table.
Mysql> flush privileges;
Mysql> grant permission 1, permission 2 ,... Permission n on database name. Table name to user name @ user address identified by 'Connection password ';
Permission 1, permission 2 ,... Permission n indicates 14 permissions, including select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, and file.
When permission 1, permission 2 ,... Permission n is replaced by all privileges or all, indicating that all permissions are granted to the user.
When the database name. Table name is replaced by *. *, it grants the user the permission to operate all the tables in the database on the server.
The user address can be localhost, IP address, machine name, or domain name. You can also use '%' to connect from any address.
The 'Connection password' cannot be blank; otherwise, creation fails.
For example:
Mysql> grant select, insert, update, delete, create, drop on vtdc. employee to jee@10.163.225.87 identified by '123 ′;
To the user jee from 10.163.225.87, assign the select, insert, update, delete, create, drop and other permissions to the employee table of the database vtdc, and set the password to 123.
Mysql> grant all on vtdc. * to jee@10.10.10.87 identified by '000000 ′;
Grant the user jee from 10.163.225.87 the permission to perform all operations on all tables in the database vtdc and set the password to 123.
Mysql> grant all on *. * to jee@10.10.10.87 identified by '000000 ′;
Grant the user jee from 10.163.225.87 the permission to perform all operations on all tables in all databases and set the password to 123.
Mysql> grant all privileges on *. * to jee @ localhost identified by '000000 ′;
Grant the local user jee the permission to perform all operations on all tables in all databases, and set the password 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 the user's database
Mysql> drop database jeecnDB;
4. change the password of a specified user
@> 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;