Create and delete mysql users 1. log on to mysql remotely
Mysql-h ip-u root-p password
2. create a user
Format: grant permission on database. * to username @ login host identified by "password ";
Example 1: Add a test1 user with a password of 123456. you can log on to any host and query, add, modify, and delete all databases. It must be performed under the root user of mysql
Mysql> grant select, insert, update, delete on *. * to test1 @ "%" identified by "123456 ";
Mysql> flush privileges;
Example 2: Add a test2 user with a password of 123456. you can only log on to 192.168.2.12 and query, add, modify, and delete student in the database. It must be performed under the root user of mysql
Mysql> grant select, insert, update, delete on student. * to test2@192.168.2.12 identified by "123456 ";
Mysql> flush privileges;
Example 3: Authorize User test3 to have all the permissions of database student
Mysql> grant all privileges on student. * to test3 @ localhost identified by '123 ';
Mysql> flush privileges;
3. change user password
Mysql> update mysql. user set password = password ('000000') where User = 'test1' and Host = 'localhost ';
Mysql> flush privileges;
4. delete a user
Mysql> delete from user where user = 'test2' and host = 'localhost ';
Mysql> flush privileges;
5. delete databases and tables
Mysql> drop database name;
Mysql> drop table name;
6. delete accounts and permissions
Drop user username @ '%'
Drop user username @ localhost