首页 > 数据库 >mysql: auth_socket登录

mysql: auth_socket登录

时间:2024-08-13 14:48:45浏览次数:10  
标签:socket ADMIN CREATE auth REPLICATION USER mysql root localhost

一,默认安装的mysql用户root是auth_socket方式登录

root@localhost的authentication_string为空,
      它的plugin为auth_socket

二,如何登录?

1,从命令行正常登录会报错:

liuhongdi@lhdpc:/data/site/gsapi$ mysql -u root -h localhost -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

2,用sudo mysql 命令可以登录到mysql

liuhongdi@lhdpc:/data/site/gsapi$ sudo mysql
[sudo] liuhongdi 的密码: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 949
Server version: 8.0.29-0ubuntu0.21.10.2 (Ubuntu)

Copyright (c) 2000, 2022, 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.

三,比较默认root用户和普通用户的区别:

比较默认的'root'@'localhost'与普通用户的区别

mysql> show grants for 'root'@'127.0.0.1';
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`127.0.0.1`                                                                                                                                                                                                                                                                                                                    |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ABORT_EXEMPT,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`@`127.0.0.1` |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants for 'root'@'localhost';
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION                                                                                                                                                                                                                                                                                                                    |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ABORT_EXEMPT,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`@`localhost` WITH GRANT OPTION |
| GRANT PROXY ON ``@`` TO `root`@`localhost` WITH GRANT OPTION                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

可以看到'root'@'localhost'的权限带有 WITH GRANT OPTION
它表示 允许被授权用户把所获权限传递授予其他用户

标签:socket,ADMIN,CREATE,auth,REPLICATION,USER,mysql,root,localhost
From: https://www.cnblogs.com/architectforest/p/18356924

相关文章

  • mysql: 用户管理
    一,新建用户CREATEUSER'laoliu'@'127.0.0.1'IDENTIFIEDBY'laoliupassword'; 二,修改用户密码8.0.3及以后SETPASSWORDFOR'laoliu'@'127.0.0.1'='laoliupass1';8.0.3之前ALTERUSER'laoliu'@'127.......
  • 高性能的 C++ Web 开发框架 CPPCMS + WebSocket 模拟实现聊天与文件传输案例。
    1.项目结构2.config.json{"service":{"api":"http","port":8080,"ip":"0.0.0.0"},"http":{"script":"",&q......
  • mysql: Usage权限
    一,Usage权限的功能1,官方的解释可以看到官方的说明:无权限,只允许连接到数据库2,Usage是连接(登陆)权限,当建立一个用户时,就会自动授予其usage权限(默认授予)。该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。 二,测试:创建用户后......
  • MySQL InnoDB Cluster – how to manage a split-brain situation
    本文是翻译MySQLInnoDBCluster–howtomanageasplit-brainsituation[1]这篇文章,如有翻译不妥或不对的地方,敬请谅解与指正。请尊重原创和翻译劳动成果,转载的时候请注明出处。谢谢!每次我展示MySQLInnoDBCluster时,在创建集群的演示中,很多人都不明白为什么当我集群中已有2......
  • MySQL中INT(3)与INT(11)
    本文由ChatMoney团队出品开篇在MySQL数据库设计的世界里,数据类型的选择是一项基础而又至关重要的任务。其中,INT数据类型因其广泛的应用和灵活性备受青睐。然而,围绕着INT(3)与INT(11)的具体差异,常常存在一些误解。本文旨在深入探讨这两者的本质,揭开它们在存储、显示及实际应用......
  • Socket 可以填IP 域名也行 防止进程修改 计算 脚本跟踪调试 用带编号的日志
    网址带http 域名不带http 实例:  www.dududu.compp.com人家这域名就这样的带斜杠的是目录php的网址域名后面是php的协议,访问的是php的阿帕奇服务器哪一个是域名是能认出来的  注册表API可以修改操作系统,这玩仍得对照书和应用程序接口网站上面写的函数然后开......
  • 在 C# 中使用 Socket.Poll() 提高 CPU 利用率
    一、背景       最近在使用Sharp7.cs连接西门子PLC时,发现当在同一台工控机上连接多个(实际超过100)CPU时,工控机的CPU占用非常大,会去到20~30%。然而此时实际的网络流量确并不高,只有10mbps。大量CPU资源消耗不知道在做什么。因为此时工控机上也没有跑其他业务代码......
  • MySQL——删除数据(三)使用关键字 TRUNCATE 删除表中数据
        在MySQL数据库中,还有一种方式可以用来删除表中所有的记录,这种方式需要用到一个关键字TRUNCATE,其语法格式如下:TEUNCATE[TABLE]表名        TRUNCATE的语法格式很简单,只需要通过“表名”指定要执行删除操作的表即可。下面通过一个案例来演示TRUN......
  • MySQL——单表查询(一)简单查询(1)SELECT语句
        MySQL从数据表中查询数据的基本语句是SELECT语句。在SELECT语句中,可以根据自己对数据的需求,使用不同的查询条件,SELECT语句的基本语法格式如下:SELECT[DISTINCT]*|字段名1,字段名2,字段名3,…FROM表名[WHERE条件表达式1][GR......
  • MySQL时区设置和查看
    检查:操作系统的时区MYSQL的时区 中国标准时间(CST)在修改系统时间之后,重新启动MySQL服务器,以确保修改生效。 mysql时区查看‌MySQL时区设置查看全局和会话时区使用命令SELECT@@global.time_zone,@@session.time_zone;可以查看全局和会话的时区设置。......