去评论
海欣资源

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

perll
2022/05/29 09:41:23
涓銆丮ySQL杩炴帴灞傦細
杩炴帴灞備负姣忎釜杩炴帴缁存姢涓涓嚎绋嬨傝绾跨▼澶勭悊鏌ヨ鎵ц銆 鍦ㄨ繛鎺ュ彲浠ュ紑濮嬪彂閫 SQL 鏌ヨ涔嬪墠锛岃繛鎺ョ敱楠岃瘉鐢ㄦ埛鍚嶃佸瘑鐮佸拰瀹㈡埛绔富鏈恒 杩炴帴灞傞氳繃澶氱杩炴帴鍗忚鎺ュ彈鏉ヨ嚜搴旂敤绋嬪簭鐨勮繛鎺ワ細
    TCP/IP
    UNIX 濂楁帴瀛
    鍏变韩鍐呭瓨
    鍛藉悕绠¢亾
濡備笅鍥炬墍绀猴細

浜屻佽繛鎺ュ崗璁細
    鍗忚鍦ㄥ鎴风搴撳拰椹卞姩绋嬪簭涓疄鐜般
    杩炴帴鍗忚鐨勯熷害鍥犳湰鍦拌缃屽紓銆
    闄や簡鏃х増 MySQL 缁忓吀鍗忚涔嬪锛孧ySQL X 鍗忚杩樺紩鍏ヤ簡MySQL 5.7.12 骞跺湪 MySQL 8.0 涓粯璁ゅ惎鐢ㄣ


MySQL 浣跨敤 TCP 灏嗘秷鎭粠瀹㈡埛绔氳繃缃戠粶浼犺緭鍒版湇鍔″櫒锛屽彲浠ヤ娇鐢ㄤ互 mysqlx 涓哄墠缂鐨勫彉閲忓拰閫夐」鏉ラ厤缃 MySQL X 鍗忚銆
    mysqlx 鍙橀噺鐨勪竴浜涚ず渚嬶細
    鈥 mysqlx
    鈥 mysqlx_bind_address
    鈥 mysqlx_max_connections
    鈥 mysqlx_port
    鈥 mysqlx_socket

涓夈佹湰鍦板拰杩滅▼杩炴帴鍗忚锛歍CP/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 绔彛銆傝繖涓虹敤浜庢櫘閫氳繛鎺ョ殑缃戠粶鎺ュ彛涓婂厑璁哥殑鍗曚釜绠$悊杩炴帴鎻愪緵浜嗕竴绉嶆浛浠f柟娉曪紝鍗充娇宸茬粡寤虹珛浜 max_connections 杩炴帴銆傚彧鏈夊湪鍚姩鏃惰缃簡 admin_address 绯荤粺鍙橀噺浠ユ寚绀虹鐞嗘帴鍙g殑 IP 鍦板潃鏃讹紝璇ユ帴鍙f墠鍙敤銆傚鏋滄湭鎸囧畾 admin_address 鍊硷紝鍒欐湇鍔″櫒涓嶇淮鎶ょ鐞嗙晫闈

    鍙湁SERVICE_CONNECTION_ADMIN 鏉冮檺鐨勭敤鎴锋墠鍏佽杩炴帴銆傛病鏈夐檺鍒剁鐞嗚繛鎺ョ殑鏁伴噺銆 MySQL 鏈嶅姟鍣ㄤ娇鐢 DNS锛堝煙鍚嶇郴缁燂級鏉ヨВ鏋愪娇鐢 TCP/IP 鍗忚杩炴帴鐨勫鎴风涓绘満鐨勫悕绉帮紝骞跺皢瀹冧滑瀛樺偍鍦ㄤ富鏈虹紦瀛樹腑銆傚浜庡湪鍚嶇О瑙f瀽杩囩▼涓嚭鐜版ц兘闂鐨勫ぇ鍨嬬綉缁滐紝璇蜂娇鐢 --skip-name-resolve 閫夐」绂佺敤 DNS 鎴栧鍔 --host-cache-size 閫夐」鐨勫笺