创建用户,并给予查看指定库的权限
mysql> create user test@localhost identified by '123456abc'; # create user 'test'@'localhost' identified by '123456abc'; 都可以
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on yii2_basic.* to test@localhost; # grant all privileges on yii2admin.* to 'denson'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
给用户分配权限
mysql> grant all privileges on *.* to 'username'@'localhost' identified by 'password'
给用户分配指定库的权限
mysql> GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password';
给用户分配指定操作的权限
mysql> GRANT SELECT, UPDATE ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password';
刷新权限
mysql> flush privileges;
删除用户
mysql> drop user username@localhsot;
删除权限
mysql> REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'localhost';