mysql> desc mysql.user;
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(255) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
C:\mysql\mysql-8.0.22-winx64\bin>mysql -uuser2
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3、删除用户
注意:mysql中user是带着host本身的(具有唯一性)
基本语法:drop user 用户名@host;
mysql> drop user user2;
Query OK, 0 rows affected (0.05 sec)
mysql> grant select on mydatabase_backup.class to 'user1'@'%';
Query OK, 0 rows affected (0.07 sec)
登陆user1用户查看:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydatabase_backup |
+--------------------+
2 rows in set (0.05 sec)
mysql> use mydatabase_backup;
Database changed
mysql> show tables;
+-----------------------------+
| Tables_in_mydatabase_backup |
+-----------------------------+
| class |
+-----------------------------+
1 row in set (0.04 sec)
5.2 取消权限:revoke
权限回收:将权限从用户手中收回
基本语法:revoke 权限列表/all privileges on 数据库/.表/ from 用户;
mysql> revoke all privileges on mydatabase_backup.class from 'user1'@'%';
Query OK, 0 rows affected (0.04 sec)
登陆user1用户查看:
mysql> show tables;
+-----------------------------+
| Tables_in_mydatabase_backup |
+-----------------------------+
| class |
+-----------------------------+
1 row in set (0.04 sec)
mysql> show tables;
ERROR 1044 (42000): Access denied for user 'user1'@'%' to database 'mydatabase_backup'
mysql>
mysql -u root -p
密码置空:update mysql.user set authentication_string='' where user="root";
刷新:flush privileges;
3.客户端:
设置密码:ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';
加密规则和密码同时改.ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin'; OK
4.查看
select host,user,user password,plugin,authentication_string from mysql.user;