Mysq, a powerful relational database, its user management is of course particularly important in the development process. Next, let's take a look at the user management of mysql
1. Log in to the database
mysql -uroot -p Enter
Enter password... Enter
2. After the login is successful, switch the database
mysql>use mysql;
3. View current users
mysql>select user,host from user;
There are only two fields listed here. There are many fields in this table. Generally, these are the ones I pay more attention to:
host: access host
user: access user name
plugin: Authentication method (password encryption method)
authentication_string: a long string of characters after the password is encrypted
4. Add new users
mysql>CREATE USER 'username'@'host' IDENTIFIED BY 'password';
host: host ip, % [arbitrary ip] localhost [local] 192.168.31.22 [specified ip]
IDENTIFIED BY: Encrypt the password with the default encryption method and put it in the table.
The default encryption method needs to check the plugin in the user table. If the client does not support it, you can specify the encryption method for encryption.
mysql>CREATE USER 'username'@'host' IDENTIFIED MySqlSHA1 BY 'password';
The newly added user does not have any permissions by default, that is, useage, and can only log in.
Note: Allowing remote is to change the user's access address from localhost to % or specify ip. After allowing remote, you must set permissions, otherwise the user can only log in, and nothing else can be done. Of course, you want to play with him, You can, as long as you are happy.
9. User operation, the last step, update permissions
mysql>flush privileges
Okay! Only share so much, wait for me to drink some ink and come back to continue.