微信扫一扫 分享朋友圈

已有 1049 人浏览分享

开启左侧

MySQL8.0连接协议以及3306、33060、33062端口作用介绍

[复制链接]
1049 0
一、MySQL连接层:
连接层为每个连接维护一个线程。该线程处理查询执行。 在连接可以开始发送 SQL 查询之前,连接由验证用户名、密码和客户端主机。 连接层通过多种连接协议接受来自应用程序的连接:
    TCP/IP
    UNIX 套接字
    共享内存
    命名管道
如下图所示:
image.png
二、连接协议:
    协议在客户端库和驱动程序中实现。
    连接协议的速度因本地设置而异。
    除了旧版 MySQL 经典协议之外,MySQL X 协议还引入了MySQL 5.7.12 并在 MySQL 8.0 中默认启用。

image.png
MySQL 使用 TCP 将消息从客户端通过网络传输到服务器,可以使用以 mysqlx 为前缀的变量和选项来配置 MySQL X 协议。
    mysqlx 变量的一些示例:
    • mysqlx
    • mysqlx_bind_address
    • mysqlx_max_connections
    • mysqlx_port
    • mysqlx_socket

三、本地和远程连接协议:TCP/IP
    TCP/IP(传输控制协议/互联网协议):
    1、是用于连接 Internet 上的主机的连接协议套件
    2、使用 IP 地址或 DNS 主机名来识别主机
    3、使用 TCP 端口号来标识每个主机上的特定服务
    MySQL 默认 TCP 端口号:
    1、3306 用于 MySQL Classic 协议(服务器端口选项)
    2、33060 用于 MySQL X 协议(服务器 mysqlx_port 选项)
    3、33062 用于使用 MySQL Classic 协议的管理连接(服务器 admin_port 选项)

修改my.cnf
admin_address='localhost'

修改前后对比:

  1. [root@hadoop1 ~]# mysql -e "show variables like 'admin%'";
  2. +------------------------+-----------------+
  3. | Variable_name          | Value           |
  4. +------------------------+-----------------+
  5. | admin_address          |                 |
  6. | admin_port             | 33062           |
  7. | admin_ssl_ca           |                 |
  8. | admin_ssl_capath       |                 |
  9. | admin_ssl_cert         |                 |
  10. | admin_ssl_cipher       |                 |
  11. | admin_ssl_crl          |                 |
  12. | admin_ssl_crlpath      |                 |
  13. | admin_ssl_key          |                 |
  14. | admin_tls_ciphersuites |                 |
  15. | admin_tls_version      | TLSv1.2,TLSv1.3 |
  16. +------------------------+-----------------+
  17. [root@hadoop1 ~]# systemctl restart mysqld.service
  18. [root@hadoop1 ~]# mysql -e "show variables like 'admin%'";
  19. +------------------------+-----------------+
  20. | Variable_name          | Value           |
  21. +------------------------+-----------------+
  22. | admin_address          | localhost       |
  23. | admin_port             | 33062           |
  24. | admin_ssl_ca           |                 |
  25. | admin_ssl_capath       |                 |
  26. | admin_ssl_cert         |                 |
  27. | admin_ssl_cipher       |                 |
  28. | admin_ssl_crl          |                 |
  29. | admin_ssl_crlpath      |                 |
  30. | admin_ssl_key          |                 |
  31. | admin_tls_ciphersuites |                 |
  32. | admin_tls_version      | TLSv1.2,TLSv1.3 |
  33. +------------------------+-----------------+
  34. [root@hadoop1 ~]#
复制代码
成功登录:
  1. [root@hadoop1 ~]# mysql -P 33062
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 17
  4. Server version: 8.0.28 MySQL Community Server - GPL

  5. Copyright (c) 2000, 2022, Oracle and/or its affiliates.

  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.

  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  10. mysql>
复制代码
网络监听情况:
  1. [root@hadoop1 ~]# netstat -anltp | grep 33062
  2. tcp        0      0 127.0.0.1:33062         0.0.0.0:*               LISTEN      1104641/mysqld      
  3. [root@hadoop1 ~]#
复制代码
设置最大连接数方便测试:
  1. mysql> set global max_connections = 1;
  2. Query OK, 0 rows affected (0.00 sec)
复制代码
重新连接:
  1. [root@hadoop1 ~]# mysql
  2. ERROR 1040 (HY000): Too many connections
  3. [root@hadoop1 ~]# mysql -P 33062 --protocol tcp
  4. Welcome to the MySQL monitor.  Commands end with ; or \g.
  5. Your MySQL connection id is 21
  6. Server version: 8.0.28 MySQL Community Server - GPL

  7. Copyright (c) 2000, 2022, Oracle and/or its affiliates.

  8. Oracle is a registered trademark of Oracle Corporation and/or its
  9. affiliates. Other names may be trademarks of their respective
  10. owners.

  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  12. mysql>
复制代码
从 MySQL 8.0.14 开始,MySQL 服务器允许专门为管理连接配置 TCP/IP 端口。这为用于普通连接的网络接口上允许的单个管理连接提供了一种替代方法,即使已经建立了 max_connections 连接。只有在启动时设置了 admin_address 系统变量以指示管理接口的 IP 地址时,该接口才可用。如果未指定 admin_address 值,则服务器不维护管理界面。

    只有SERVICE_CONNECTION_ADMIN 权限的用户才允许连接。没有限制管理连接的数量。 MySQL 服务器使用 DNS(域名系统)来解析使用 TCP/IP 协议连接的客户端主机的名称,并将它们存储在主机缓存中。对于在名称解析过程中出现性能问题的大型网络,请使用 --skip-name-resolve 选项禁用 DNS 或增加 --host-cache-size 选项的值。

免责声明:
1,海欣资源网所发布的资源由网友上传和分享,不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
2,海欣资源网的资源来源于网友分享,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3,海欣资源网所发布的资源由网友上传和分享,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
4,如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉,联系方式邮箱 haixinst@qq.com
海欣资源-企业信息化分享平台。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

0

关注

0

粉丝

43

主题
热度排行
回复排行
最新贴子

Archiver|手机版|海欣资源 ( 湘ICP备2021008090号-1 )|网站地图

GMT+8, 2024-4-27 15:25 , Gzip On, MemCached On.

免责声明:本站所发布的资源和文章均来自网络,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。 本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。 如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉。