Mysql创建新用户并赋予权限

1.创建用户

create user '用户名'@'localhost'identified by'密码';

mysql> create user 'bwj'@'localhost'  identified by'666666';
Query OK, 0 rows affected (0.00 sec)

2.赋予全部权限

grant all on 权限 to 用户名@'localhost' identified by "密码";

mysql> grant all on *.* to bwj@'localhost' identified by "666666";
Query OK, 0 rows affected, 1 warning (0.01 sec)

3.查看用户权限

show grants for '用户名'@'localhost';

mysql> show grants for 'bwj'@'localhost';
+--------------------------------------------------+
| Grants for bwj@localhost                         |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'bwj'@'localhost' |
+--------------------------------------------------+
1 row in set (0.00 sec)

4.查看用户名

select user,host from mysql.user;

mysql> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| bwj              | localhost |
| debian-sys-maint | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
| www              | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)

写作不易,望多多支持、点赞、收藏、赞赏!

希望用心的制作能对您有所帮助!

你可能感兴趣的:(Mysql创建新用户并赋予权限)