zno2

创建用户 和 授权

https://dev.mysql.com/doc/refman/5.7/en/create-user.html

https://dev.mysql.com/doc/refman/5.7/en/grant.html

这个搜索非常好用

 

CREATE USER
  'u1'@'%' IDENTIFIED  BY 'aB123456_+',
  'u2'@'%' IDENTIFIED  BY 'aB123456_+',
  'u3'@'%' IDENTIFIED  BY 'aB123456_+',
  'u4'@'%' IDENTIFIED  BY 'aB123456_+',
  'u5'@'%' IDENTIFIED  BY 'aB123456_+',
  'u6'@'%' IDENTIFIED  BY 'aB123456_+',
  'u7'@'%' IDENTIFIED  BY 'aB123456_+',
  'u8'@'%' IDENTIFIED  BY 'aB123456_+'
  ;

提示:如果 @'localhost' 则无法远程登录

 

删除用户

DROP USER 'u1'@'%';
DROP USER 'u2'@'%';
DROP USER 'u3'@'%';
DROP USER 'u4'@'%';
DROP USER 'u5'@'%';
DROP USER 'u6'@'%';
DROP USER 'u7'@'%';
DROP USER 'u8'@'%';

 

 

如果提示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

可以查看密码策略

mysql> SHOW VARIABLES LIKE 'validate_password%'; 
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_check_user_name    | OFF    |
| validate_password_dictionary_file    |        |
| validate_password_length             | 8      |
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM |
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.00 sec)

 

查看数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| overloaddb         |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.16 sec)

 

分配权限(仅能看到哪些表)

GRANT ALL ON yourdb.yourtable1 TO 'u1'@'%';
GRANT ALL ON yourdb.yourtable2 TO 'u1'@'%';

 

posted on 2023-06-06 13:16  zno2  阅读(11)  评论(0编辑  收藏  举报

导航