mysql> create user test @'localhost' identified by '123456'
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
注:如果host是%的話,任何的IP都可以通路。這是不可取的
使用者授權
需要在root或者大權限的使用者下操作
grant create,update,select,delete on ssm.* to test @'localhost'
撤銷權限
revoke create,update,select,delete on ssm.* from test @'localhost'
檢視使用者的權限
mysql> show grants for [email protected];
+--------------------------------------------------------------------------+
| Grants for [email protected] |
+--------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT, UPDATE, DELETE, CREATE ON `ssm`.* TO 'test'@'localhost' |
+--------------------------------------------------------------------------+
2 rows in set (0.00 sec)
删除使用者
mysql> drop user [email protected];
Query OK, 0 rows affected (0.00 sec)