【MySQL】如何使用Shared-memory協議(Windows)連接MySQL數據庫

文章目錄

  • 【MySQL】如何使用Shared-memory協議(Windows)連接MySQL數據庫
    • 連接MySQL的協議
    • 使用Shared-memory協議(Windows)連接MySQL
      • 步驟1:確認MySQL服務器已啟用Shared-memory連接
        • 啟動Shared-memory連接方法
      • 步驟2:客戶端使用shared-memory連接MySQL服務器。
        • 例1:客戶端使用shared-memory連接MySQL服務器
        • 例2:默認連接MySQL服務器
      • 常見錯誤
    • 小結

【MySQL】如何使用Shared-memory協議(Windows)連接MySQL數據庫

連接MySQL的協議

在MySQL中可以通過指定 --protocol參數,選擇連接MySQL的協議。

連接協議(Connection Protocals):

--protocol={TCP|SOCKET|PIPE|MEMORY}TCP/IP  (ALL)  -Transmission Control Protocal/Internet Protocal-Connection:local & remote-Supports Clasic & X protocol
Socket  file (Unix including Linux/Mac) -Connection:local -Supports Clasic & X protocol
Named Pipe    (Win)  -Connection:local -Supports Clasic
Shared Memory (Win)  -Connection:local -Supports Clasic

參考:
https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_protocol
>4.2.3 Command Options for Connecting to the Server

使用Shared-memory協議(Windows)連接MySQL

在Windows環境中支持共享內存(Shared-memory)連接連接MySQL。
如果服務器啟用了Shared-memory連接,客戶端就可以通過使用–protocol=MEMORY選項使用Shared-memory連接MySQL。

使用Shared-memory協議(Windows)連接MySQL時,能夠提高MySQL的性能,具體測評請參考如下官方鏈接的介紹。

參考:
Improving the Performance of MySQL on Windows
https://dev.mysql.com/blog-archive/improving-the-performance-of-mysql-on-windows/

步驟1:確認MySQL服務器已啟用Shared-memory連接

查看是否啟用Shared-memory連接。

mysql> show variables like 'shared_memory';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| shared_memory | OFF   |
+---------------+-------+
1 row in set, 1 warning (0.03 sec)mysql>

如果值是ON,則表示啟用;OFF表示禁用狀態。

啟動Shared-memory連接方法

  1. 打開配置文件my.ini,將shared-memory變量和shared-memory-base-name變量前的注釋去掉并保存。

例:

# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipeshared-memoryshared-memory-base-name=MYSQL

※ my.ini文件的位置可以通過【mysql --help】命令中的Default options內容查看。
例:

Default options are read from the following files in the given order:
C:\windows\my.ini C:\windows\my.cnf C:\my.ini C:\my.cnf E:\Soft\MySQL8.0\my.ini E:\Soft\MySQL8.0\my.cnf```
  1. 重新啟動MySQL服務器。
net stop <MySQL服務名>
net start <MySQL服務名>

例:

C:\Users\Administrator>net stop mysql80
MySQL80 服務正在停止.
MySQL80 服務已成功停止。C:\Users\Administrator>net start mysql80
MySQL80 服務正在啟動 ..
MySQL80 服務已經啟動成功。

3.查看shared-memory連接啟用狀態。

C:\Users\Administrator>mysql  -u root -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 MySQL Community Server - GPLCopyright (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.mysql>  show variables like 'shared_memory';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| shared_memory | ON    |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)mysql>

步驟2:客戶端使用shared-memory連接MySQL服務器。

例1:客戶端使用shared-memory連接MySQL服務器

通過指定–protocol=MEMORY,客戶端可以使用shared-memory連接MySQL服務器。

C:\Users\Administrator>mysql --protocol=MEMORY -u root -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28 MySQL Community Server - GPLCopyright (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.mysql> \s
--------------
mysql  Ver 8.0.28 for Win64 on x86_64 (MySQL Community Server - GPL)Connection id:          9
Current database:
Current user:           root@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         8.0.28 MySQL Community Server - GPL
Protocol version:       10
Connection:             Shared memory: MYSQL
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gbk
Conn.  characterset:    gbk
TCP port:               0
Binary data as:         Hexadecimal
Uptime:                 1 min 58 secThreads: 2  Questions: 12  Slow queries: 0  Opens: 134  Flush tables: 3  Open tables: 53  Queries per second avg: 0.101
--------------mysql>

例2:默認連接MySQL服務器

啟用shared-memory連接后,不指定–protocol時本地連接也會使用shared-memory連接MySQL服務器。

C:\Users\Administrator>mysql  -u root -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.28 MySQL Community Server - GPLCopyright (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.mysql> \s
--------------
mysql  Ver 8.0.28 for Win64 on x86_64 (MySQL Community Server - GPL)Connection id:          10
Current database:
Current user:           root@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         8.0.28 MySQL Community Server - GPL
Protocol version:       10
Connection:             Shared memory: MYSQL
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gbk
Conn.  characterset:    gbk
TCP port:               0
Binary data as:         Hexadecimal
Uptime:                 3 min 52 secThreads: 2  Questions: 17  Slow queries: 0  Opens: 134  Flush tables: 3  Open tables: 53  Queries per second avg: 0.073
--------------mysql>

常見錯誤

當服務器shared memory連接未啟用的時候,使用shared memory連接會報如下的錯誤:

C:\Users\Administrator>mysql --protocol=MEMORY -u root -p
Enter password: ********
ERROR 2038 (HY000): Can't open shared memory; client could not create request event (2)

可參考如上的方法在服務器端進行相應的配置。

小結

本文介紹了在Windows環境中,如何使用shared memory協議連接MySQL數據庫的方法。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/43483.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/43483.shtml
英文地址,請注明出處:http://en.pswp.cn/news/43483.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

神經網絡基礎-神經網絡補充概念-55-為什么是ML策略

“ML策略”&#xff08;Machine Learning Strategies&#xff09;是指在解決機器學習問題時&#xff0c;采取的一系列方法、技巧和策略。選擇適當的ML策略對于獲得高質量的模型和結果非常重要。以下是為什么要考慮ML策略的一些原因&#xff1a; 問題適應性&#xff1a;不同的機…

2023 最新版網絡安全保姆級指南,從 0 基礎進階網絡攻防工程師

一、網絡安全學習的誤區 1.不要試圖以編程為基礎去學習網絡安全 不要以編程為基礎再開始學習網絡安全&#xff0c;一般來說&#xff0c;學習編程不但學習周期長&#xff0c;且過渡到網絡安全用到編程的用到的編程的關鍵點不多。一般人如果想要把編程學好再開始學習網絡安全往…

Vue實例生命周期中的所有鉤子函數

在 Vue 3 中&#xff0c;實例生命周期的鉤子函數被整合為了兩個主要的階段&#xff1a;Composition API 階段和 Options API 階段。下面是 Vue 3 中的所有生命周期鉤子函數&#xff1a; Composition API 階段&#xff1a; setup //在組件實例創建之前執行&#xff0c;用于設…

centos 之安裝 openssl 1.1.1報錯

源碼make時報錯&#xff0c;可能是系統的perl的版本太低問題。 [rootlocalhost ~]# cpan -a | grep Test::More Test::More 0.92 1.302171 EXODIST/Test-Simple-1.302171.tar.gz [rootlocalhost ~]# cpan -a | grep Text::Template [rootlocalhost ~]# …

Dockerfile小記(持續)

文章目錄 信息新建用戶服務重啟數據庫相關SSH無交互安裝auth.logssh開機自啟 Apache服務配置 信息 Alpine系統 新建用戶 useradd命令參考 RUN apk update \ && apk add shadow \&& useradd -m togie \&& echo togie:12345 | chpasswd \&& &…

nginx負載均衡配置案例

一、nginx代理配置 ## 定義一個集群&#xff0c;名稱叫做load_balancer_testupstream load_balancer_test {#ip_hash是負載均衡策略#ip_hash;#集群下有兩個服務server 192.168.1.233:8087;server 192.168.1.243:8087;}server {#監聽8600端口listen 8600;server_name loc…

Lnton羚通關于PyTorch的保存和加載模型基礎知識

SAVE AND LOAD THE MODEL (保存和加載模型) PyTorch 模型存儲學習到的參數在內部狀態字典中&#xff0c;稱為 state_dict, 他們的持久化通過 torch.save 方法。 model models.shufflenet_v2_x0_5(pretrainedTrue) torch.save(model, "../../data/ShuffleNetV2_X0.5.pth…

vue2.6升級vue2.7(panjiachen升級指南)vue-cli5多頁面應用升級的坑

vue2.7升級指南 vue2.7升級指南 之前的架子使用的是 panjiachen&#xff0c;使用的是 vue2.6.14&#xff0c;現在升級為 vue2.7.x 升級vue/cli vue upgrade 這里推薦使用 vue upgrade 命令自動升級 # 確保安裝全局 vue/cli $ npm install -g vue/cli $ vue upgradeWARN Th…

水庫大壩安全監測MCU,提升大壩管理效率的利器!

水庫大壩作為防洪度汛的重要設施&#xff0c;承擔著防洪抗旱&#xff0c;節流發電的重要作用。大壩的安全直接關系到水庫的安全和人民群眾的生命財產安全。但因為水庫大壩的隱患不易被察覺&#xff0c;發現時往往為時已晚。因此&#xff0c;必須加強對大壩的安全管理。其安全監…

RFID技術助力汽車零配件裝配產線,提升效率與準確性

隨著科技的不斷發展&#xff0c;越來越多的自動化設備被應用到汽車零配件裝配產線中。其中&#xff0c;射頻識別&#xff08;Radio Frequency Identification&#xff0c;簡稱RFID&#xff09;技術憑借其獨特的優勢&#xff0c;已經成為了這一領域的重要技術之一。本文將介紹RF…

【SLAM】ORBSLAM34macOS: ORBSLAM3 Project 4(for) macOS Platform

文章目錄 配置ORBSLAM34macOS 版本運行步驟&#xff1a;版本修復問題記錄&#xff1a;編譯 fix運行 fix 配置 硬件&#xff1a;MacBook Pro Intel CPU 系統&#xff1a;macOS Ventura 13.4.1 ORBSLAM34macOS 版本 https://github.com/phdsky/ORB_SLAM3/tree/macOS 運行步驟&…

初識結構體

文章目錄 目錄1. 結構體類型的聲明1.1 結構的基礎知識1.2 結構的聲明1.3 結構成員的類型1.4 結構體變量的定義和初始化 2. 結構體成員的訪問3. 結構體傳參 目錄 結構體類型的聲明結構體初始化結構體成員訪問結構體傳參 1. 結構體類型的聲明 1.1 結構的基礎知識 結構是一些值的…

三維可視化平臺有哪些?Sovit3D可視化平臺怎么樣?

隨著社會經濟的發展和數字技術的進步&#xff0c;互聯網行業發展迅速。為了適應新時代社會發展的需要&#xff0c;大數據在這個社會經濟發展過程中隨著技術的進步而顯得尤為重要。同時&#xff0c;大數據技術的快速發展進程也推動了可視化技術的飛速發展&#xff0c;國內外各類…

四層和七層負載均衡的區別

一、四層負載均衡 四層就是ISO參考模型中的第四層。四層負載均衡器也稱為四層交換機&#xff0c;它主要時通過分析IP層和TCP/UDP層的流量實現的基于“IP端口”的負載均衡。常見的基于四層的負載均衡器有LVS、F5等。 以常見的TCP應用為例&#xff0c;負載均衡器在接收到第一個來…

hive-無法啟動hiveserver2

啟動hiveserver2沒有反應&#xff0c;客戶端也無法連接( beeline -u jdbc:hive2://node01:10000 -n root) 報錯如下 查看hive的Log日志&#xff0c;發現如下報錯 如何解決 在hive的hive_site.xml中添加如下代碼 <property><name>hive.server2.active.passive…

電機故障診斷(python程序,模型為MSCNN結合LSTM結合注意力機制模型,有注釋)

代碼運行環境要求&#xff1a;TensorFlow版本>2.4.0&#xff0c;python版本>3.6.0 1.電機常見的故障類型有以下幾種&#xff1a; 軸承故障&#xff1a;軸承是電機運轉時最容易受損的部件之一。常見故障包括磨損、疲勞、過熱和潤滑不良&#xff0c;這些問題可能導致噪音增…

Hlang--用Python寫個編程語言-判斷與循環

文章目錄 前言語法描述判斷循環詞法解析語法解析定義節點生成節點判斷節點循環節點解釋器處理判斷節點循環處理前言 okey,很好,在上一篇文章當中,我們實現了這個基本的邏輯運算,所以的話,在這里,我們將可以實現到我們的這個判斷和循環了。由于這里的話,我們的操作其實和…

TiDB Bot:用 Generative AI 構建企業專屬的用戶助手機器人

本文介紹了 PingCAP 是如何用 Generative AI 構建一個使用企業專屬知識庫的用戶助手機器人。除了使用業界常用的基于知識庫的回答方法外&#xff0c;還嘗試使用模型在 few shot 方法下判斷毒性。 最終&#xff0c;該機器人在用戶使用后&#xff0c;點踩的比例低于 5%&#xff0…

汽車租賃管理系統/汽車租賃網站的設計與實現

摘 要 租賃汽車走進社區&#xff0c;走進生活&#xff0c;成為當今生活中不可缺少的一部分。隨著汽車租賃業的發展&#xff0c;加強管理和規范管理司促進汽車租賃業健康發展的重要推動力。汽車租賃業為道路運輸車輛一種新的融資服務形式、廣大人民群眾一種新的出行消費方式和…

龍蜥社區安全聯盟(OASA)正式成立,啟明星辰、綠盟、360 等 23 家廠商重磅加入

7 月 28 日&#xff0c;由啟明星辰、綠盟、360、阿里云、統信軟件、浪潮信息、中興通訊&#xff5c;中興新支點、Intel、中科院軟件所等 23 家單位共同發起的龍蜥社區安全聯盟&#xff08;OASA&#xff0c;OpenAnolisSecurityAlliance&#xff09;&#xff08;以下簡稱“安全聯…