mysql new user, authorization and revoking permissions

Previous articleOn Debian, I used mysql_setpermission to create a new user and authorize it. But my cloud server is winserver, I tried dos without mysql_setpermission command, only mysql . So this article will talk about how to create a new user and authorize the mysql command.
Generally, for security reasons, it is recommended that the root account close remote connections and only allow local logins. Then create another account that opens remote connections, set the database that allows operations, and assign permissions for adding, deleting, modifying, and checking.
Login to mysql:

mysql -u root -p

Enter the database:

show databases;
use mysql;

Modify root to log in locally:

show tables;
update user set host='localhost' where user='root';
flush privileges; 

Create a new authorized user:

grant SELECT,INSERT,UPDATE,DELETE on databasename.* to 'canva'@'%' identified by '123456';
flush privileges;

Check if it works:

select host,user from user;

If you want to revoke permissions:

revoke SELECT,INSERT,UPDATE,DELETE on databasename.* from 'canva'@'%';

So far you're done, the key is to learn the mysql.user table!

Guess you like

Origin blog.csdn.net/CanvaChen/article/details/52758370