文章目录
1、查询所有用户
1.1、登录数据库
[root@localhost~]# docker exec -it spzx-mysql /bin/bash
root@ab66508d9441:/# mysql -uroot -p123456
mysql: [Warning]Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands endwith;or \g.
Your MySQL connection id is71
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c)2000,2021, Oracle and/or its affiliates.
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.
SELECTuser, host FROM mysql.user;
1.2、select user,host from mysql.user;
mysql>selectuser,host from mysql.user;+------------------+-----------+|user| host |+------------------+-----------+| atguigu_slave |%|| root |%|| mysql.infoschema | localhost || mysql.session| localhost || mysql.sys | localhost || root | localhost |+------------------+-----------+6rowsinset(0.00 sec)
用户 atguigu_slave 是搭建mysql的主从复制创建的:mysql-搭建主从复制:https://blog.csdn.net/m0_65152767/article/details/142214434
2、查看用户的权限
SHOW GRANTS FOR'username'@'host';
mysql>show grants for'root'@'%';+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Grants for root@%|+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|GRANTSELECT,INSERT,UPDATE,DELETE,CREATE,DROP, RELOAD,SHUTDOWN, PROCESS,FILE,REFERENCES,INDEX,ALTER,SHOWDATABASES, SUPER,CREATETEMPORARYTABLES,LOCKTABLES,EXECUTE,REPLICATION SLAVE,REPLICATION CLIENT,CREATEVIEW,SHOWVIEW,CREATEROUTINE,ALTERROUTINE,CREATEUSER, EVENT,TRIGGER,CREATETABLESPACE,CREATE ROLE,DROP ROLE ON*.*TO`root`@`%`WITHGRANTOPTION||GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,AUTHENTICATION_POLICY_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,GROUP_REPLICATION_STREAM,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PASSWORDLESS_USER_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON*.*TO`root`@`%`WITHGRANTOPTION|+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+2rowsinset(0.01 sec)
本文转载自: https://blog.csdn.net/m0_65152767/article/details/142489708
版权归原作者 小丁学Java 所有, 如有侵权,请联系我们删除。
版权归原作者 小丁学Java 所有, 如有侵权,请联系我们删除。