Create a new user
create user lisi identified by '123456';
View create results:
Authorize
命令格式:grant privilegesCode on dbName.tableName to username@host identified by "password";
Command Description:
privilegesCode express grant of permission types, common are:
- all privileges: All rights;
- select: Read permission;
- delete: delete permissions;
- update: Update authority;
- create: Create permission;
- drop: delete the database, data table permissions.
dbName.tableName express permission granted to specific database or table, commonly used are:
- "* . * " Dot represents the permissions granted to the user all databases and tables;
- dbName . *: dbName granted permission to the database all the tables;
- dbName.dbTable: grant permissions in the database dbName dbTable table.
username @ host expressed in the host allowed to log IP, common are:
- localhost : only allow the user to log on locally, not remotely log in;
- %: Allow remote login;
- 192.168.12.34 : specific IP represents only allows the user to log in from a particular IP.
Create a new database dblisi: create database dblisi;
Empowering John Doe to use database dblisi: allow remote password is 123456
grant all privileges on dblisi.* to lisi@'%' identified by '123456';
Refresh permissions: flush privileges;
Log with account lisi: mysql -u lisi -p
Enter the password 123456
After landing successfully switched database:
Visible only have access to the database dblisi.
update mysql.user set password = password('12345678') where user = 'lisi' ;
Change password
Log in to directly modify the user's password:
Although 0 rows affected, refresh failure, but make way 123 with a password to log in;
Remote can also be connected:
Log root, change the password for the 123, refresh, as follows:
Similarly 0 rows affected, but refreshing success;
Telnet has been a failure:
This is a strange phenomenon. It seems to change the root password using the set password is not OK. For a way:
connection succeeded!
Note, authentication_string is the password field under the new version of mysql.
delete users
drop user username@'%';