日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 管理端口_MySQL8新增管理端口

發(fā)布時間:2025/3/19 数据库 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 管理端口_MySQL8新增管理端口 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡介

用過MySQL數(shù)據(jù)庫朋友一定對“ERROR 1040 (HY000): Too many connections”,這個報錯不陌生,出現(xiàn)這個報錯的原因有兩種情況,一種是單個用戶的連接數(shù)超過“max_user_connections”參數(shù)定義值,另外一種情況是,所有應(yīng)用的連接數(shù)超過“max_connections”參數(shù)定義值。

如果是第二種情況,MySQL數(shù)據(jù)庫還提供一個額外連接,這個連接只有super角色的用戶能登錄,例如root用戶,使用root用戶登錄數(shù)據(jù)庫之后,就可以進行故障定位。但是如果由于管理不規(guī)范,應(yīng)用程序使用了super角色用戶連接數(shù)據(jù),當出現(xiàn)“ERROR 1040 (HY000): Too many connections”報錯之后,大家想想,會發(fā)生什么,這個時候DBA使用root用戶都登錄數(shù)據(jù)庫,就很難做故障定位了,去解決連接不足的問題。

MySQL8新增管理端口

在MySQL8以前的版本,由于應(yīng)用用戶和管理用戶共同使用同一個端口服務(wù),沒有進行隔離,如果使用不規(guī)范時,很容易造成DBA無法用root用戶連接數(shù)據(jù)庫,進行故障定位。

到MySQL8的版本,MySQL官方考慮到這個問題,于是就給數(shù)據(jù)庫管理人員獨立起了一個管理端口服務(wù),這樣應(yīng)用用戶和管理用戶訪問的端口進行隔離,互不影響。

MySQL8管理端口啟用

要啟用MySQL8管理端口,只需要在my.cnf配置文件中添加3個參數(shù)admin_address=127.0.0.1admin_port=33306create_admin_listener_thread=1mysql> show variables like '%admin%';+---------------------------------+-------------------------------+| Variable_name | Value |+---------------------------------+-------------------------------+| admin_address | 127.0.0.1 || admin_port | 33306 || admin_ssl_ca | || admin_ssl_capath | || admin_ssl_cert | || admin_ssl_cipher | || admin_ssl_crl | || admin_ssl_crlpath | || admin_ssl_key | || admin_tls_ciphersuites | || admin_tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 || create_admin_listener_thread | ON || log_slow_admin_statements | OFF || persist_only_admin_x509_subject | |+---------------------------------+-------------------------------+14 rows in set (0.01 sec)

下面就來測試一下,當報"ERROR 1040 (HY000): Too many connections"錯誤之后,DBA是否還能使用管理端口連接數(shù)據(jù)庫

1.模擬會話總數(shù)已經(jīng)達到max_connections參數(shù)定義閥值mysql> show variables like '%connections%';+------------------------+-------+| Variable_name | Value |+------------------------+-------+| max_connections | 3 || max_user_connections | 2 || mysqlx_max_connections | 100 |+------------------------+-------+3 rows in set (0.01 sec)mysql> show global status like 'Threads_connected';+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 3 |+-------------------+-------+1 row in set (0.01 sec)

2.使用MySQL數(shù)據(jù)庫額外提供的端口,root連接數(shù)據(jù)庫root@19dd973af376:~# mysql -uroot -prootmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 32Server version: 8.0.21 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show global status like 'Threads_connected';+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 4 |+-------------------+-------+1 row in set (0.01 sec)

此時,root用戶已經(jīng)使用了MySQL數(shù)據(jù)庫的額外連接,如果再使用root用戶連接數(shù)據(jù),就會報錯了root@19dd973af376:~# mysql -uroot -prootmysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1040 (HY000): Too many connections

3.使用管理端口連接數(shù)據(jù)庫root@19dd973af376:~# mysql -uroot -proot -P 33306 -h127.0.0.1mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 33Server version: 8.0.21 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show global status like 'Threads_connected';+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 5 |+-------------------+-------+1 row in set (0.03 sec)

可以看到root用戶還可以通過管理端口33306進行登錄了,當前的連接數(shù)總數(shù)也到了5個,超過了max_connections定義的3個。

總結(jié)

以上是生活随笔為你收集整理的mysql 管理端口_MySQL8新增管理端口的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。