1、进入mysql
2、使用某个数据库
use mysql;
3、查看已有的用户
select user from user;
4、创建用户
mysql> create user benben identified by '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> select user from user;
+------------------+
| user |
+------------------+
| benben |
| mysql.infoschema |
| mysql.session |
| mysql.sys |
| root |
+------------------+
5 rows in set (0.00 sec)
5、用新建的用户登录
6、查看数据库,只有一个库
show databases;
7、给新增的用户授予权限
8.0以后的版本
grant all privileges on mysql.* to benben@'%' with grant option;
Query OK, 0 rows affected (0.01 sec)
8.0以前的版本
grant privilegesCode on dbName.tableName to username@host identified by "password";
grant all privileges on istester.* to benben@'%' identified by '123456';
grant select,update on istester.* to benben@'%' identified by '123456';
查看权限授予情况