当前位置: 首页 > news >正文

【MySQL】如何使用Named Pipe协议(Windows)连接MySQL数据库

文章目录

  • 【MySQL】如何使用Named Pipe协议(Windows)连接MySQL数据库
    • 连接MySQL的协议
    • 使用Named Pipe协议(Windows)连接MySQL
      • 步骤1:确认MySQL服务器已启用Named Pipe连接
        • 启动Named Pipe连接方法
      • 步骤2:客户端使用Named Pipe连接MySQL服务器。
        • 例1:客户端使用Named Pipe连接MySQL服务器
        • 例2:客户端指定Socket使用Named Pipe连接MySQL服务器
      • 常见错误
    • 小结

MySQL入门02:关于MySQL连接的ABC
【MySQL】如何使用Named Pipe协议(Windows)连接MySQL数据库
【MySQL】如何使用Shared-memory协议(Windows)连接MySQL数据库
【MySQL】如何使用Unix Sockets 协议连接MySQL数据库

【MySQL】如何使用Named Pipe协议(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

使用Named Pipe协议(Windows)连接MySQL

在Windows环境中,和Unix Sockets连接MySQL相似,可以用Named Pipe协议连接MySQL。
下面介绍如何使用Named Pipe连接MySQL的步骤。

步骤1:确认MySQL服务器已启用Named Pipe连接

查看是否启用Named Pipe连接。

mysql> SHOW GLOBAL VARIABLES LIKE 'named_pipe';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| named_pipe    | OFF   |
+---------------+-------+
1 row in set, 1 warning (0.04 sec)mysql>

如果值是ON,则表示启用;OFF表示禁用状态。

启动Named Pipe连接方法

  1. 打开配置文件my.ini,将enable-named-pipe变量和socket变量前的注释去掉并保存。

例:

# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
enable-named-pipe
# shared-memory# shared-memory-base-name=MYSQL# The Pipe the MySQL Server will use.
socket=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.查看Named Pipe连接启用状态。

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 GLOBAL VARIABLES LIKE 'named_pipe';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| named_pipe    | ON    |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)mysql> SHOW  VARIABLES LIKE 'socket';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| socket        | MYSQL |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)mysql> exit
Bye

步骤2:客户端使用Named Pipe连接MySQL服务器。

例1:客户端使用Named Pipe连接MySQL服务器

通过指定–protocol=pipe,客户端可以使用Named Pipe连接MySQL服务器。

C:\Users\Administrator>mysql --protocol=pipe -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:             Named pipe: MySQL
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gbk
Conn.  characterset:    gbk
UNIX socket:            MySQL
Binary data as:         Hexadecimal
Uptime:                 7 min 22 secThreads: 2  Questions: 16  Slow queries: 0  Opens: 137  Flush tables: 3  Open tables: 56  Queries per second avg: 0.036
--------------mysql>

不指定Socket的时候,会使用默认的Named pipe: MySQL。

例2:客户端指定Socket使用Named Pipe连接MySQL服务器

C:\Users\Administrator>mysql --protocol=pipe -u root -p --socket=MYSQL
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
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:          11
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:             Named pipe: MYSQL
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gbk
Conn.  characterset:    gbk
UNIX socket:            MYSQL
Binary data as:         Hexadecimal
Uptime:                 13 min 4 secThreads: 2  Questions: 25  Slow queries: 0  Opens: 138  Flush tables: 3  Open tables: 57  Queries per second avg: 0.031
--------------mysql> exit
Bye

常见错误

当服务器Named Pipe连接未启用的时候,使用Named Pipe连接会报如下的错误:

C:\Users\Administrator>mysql --protocol=pipe -u root -prootroot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2017 (HY000): Can't open named pipe to host: .  pipe: MySQL (2)

可参考如上的方法在服务器端进行相应的配置。

小结

本文介绍了在Windows环境中,如何使用Named Pipe协议连接MySQL数据库的方法。

相关文章:

【MySQL】如何使用Named Pipe协议(Windows)连接MySQL数据库

文章目录 【MySQL】如何使用Named Pipe协议(Windows)连接MySQL数据库连接MySQL的协议使用Named Pipe协议(Windows)连接MySQL步骤1&#xff1a;确认MySQL服务器已启用Named Pipe连接启动Named Pipe连接方法 步骤2&#xff1a;客户端使用Named Pipe连接MySQL服务器。例1&#xff…...

【c++】c++的一些技术操作

pthread_create 的第三个参数&#xff0c;为函数指针&#xff0c;指向处理线程函数的地址。该函数&#xff0c;要求为静态函数。如果处理线程函数为类成员函数时&#xff0c;需要将其设置为静态成员函数。C静态成员函数访问非静态成员 https://blog.csdn.net/yueguangmuyu/arti…...

JS中对象数组深拷贝方法

structuredClone() JavaScript 中提供了一个原生 API 来执行对象的深拷贝&#xff1a;structuredClone。它可以通过结构化克隆算法创建一个给定值的深拷贝&#xff0c;并且还可以传输原始值的可转移对象。 当对象中存在循环引用时&#xff0c;仍然可以通过 structuredClone()…...

2022数学建模国赛C题官网展示论文C155论文复现

2022数学建模国赛C题C155论文复现 1.内容比对2.第一问第二小问复现代码2.1 页表合并2.2 数据的正态性检验2.2.1数据的正态性检验效果图 2.3不满足正态性&#xff0c;进行中心化对数比变换2.3.1 核心步骤-inf用0值替换2.3.2中心化对数比变换效果图 2.4描述性统计2.5 箱线图绘制 …...

阿里云 K8s PVC 绑定 StorageClass 申领 PV 失败

错误场景: 因为阿里云没有默认的 StorageClass 我也懒得更新&#xff0c;所以就创建了一个类型是云盘的 StorageClass。 但是在创建 PVC 之后发现一直是 Pending 状态就查询了一下日志&#xff0c;然后看到很多下面这种错误 liuduiMacBookM1Pro ~ % kubectl describe pvc graf…...

php数组

php数组是什么&#xff1f; 可以使用单个变量名存储多个不同类型的数据的特殊变量&#xff0c;这就是php数组。 php数组就是一个特殊的变量&#xff0c;它允许存储多个任意类型的数据。 创建数组 php数组有两种类型&#xff0c;分为索引数组和关联数组。 创建数组的方法有三种…...

构造不包含字母和数字的webshell

构造不包含字母和数字的webshell <?php echo "A"^""; ?> 输出的结果是字符"!“。之所以会得到这样的结果&#xff0c;是因为代码中对字符"A"和字符”"进行了异或操作。在PHP中&#xff0c;两个变量进行异或时&#xff0c;…...

中国大学生服务外包创新创业大赛丨借 AI 之力,助“记账”难题

一、中国大学生服务外包创新创业大赛 赛事介绍 中国大学生服务外包创新创业大赛&#xff0c;是响应国家关于鼓励服务外包产业发展、加强服务外包人才培养的相关战略举措与号召&#xff0c;举办的每年一届的全国性竞赛。 大赛均由中华人民共和国教育部、中华人民共和国商务部…...

MacOS 安装Redis并设置密码

在开发过程中&#xff0c;需要本地进行安装Redis进行测试&#xff0c;记录了下MacOS环境下安装Redis&#xff0c;以及设置密码。 Brew 安装 $ brew install redis启动服务 # 启动服务 brew services start redis # 关闭服务 brew services stop redis # 重启服务 brew servic…...

函数的参数作为引用

文章目录 1. num,list ,tuple2. list 作为默认值导致共享同一列表3. 防御可变参数4. 结论 1. num,list ,tuple 结论&#xff1a;num ,tuple 作为参数&#xff0c;自身不会因为函数的原因而改变&#xff0c;list 为可变量&#xff0c;会因为函数变而变。 测试 def f(a, b):a …...

【文化课学习笔记】【化学】非金属及其化合物

【化学】必修一&#xff1a;非金属及其化合物 硅及其化合物 硅单质 物理性质 单晶硅的结构与金刚石类似&#xff0c;为正四面体的立体网状结构。晶体中每个硅原子与其他四个硅原子相连接。\(1\mathrm{mol}\) 硅单质还有 \(\mathrm{2N_A}\) 个 \(\mathrm{Si-Si}\) 键&#xff1b…...

Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)

文章目录 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)前情提要客户端部分 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三) 前情提要 单例泛型类 using System.Collections; using System.Collections.Generic; …...

步步向前,曙光已现:百度的大模型之路

大模型&#xff0c;是今年全球科技界最火热&#xff0c;最耀眼的关键词。在几个月的狂飙突进中&#xff0c;全球主要科技公司纷纷加入了大模型领域。中国AI产业更是开启了被戏称为“百模大战”的盛况。 但喧嚣与热闹之后&#xff0c;新的问题也随之而来&#xff1a;大模型的力量…...

常见的 Python 错误及其解决方案

此文整理了一些常见的 Python 错误及其解决方案。 1、SyntaxError: invalid syntax 说明&#xff1a;无效的语法是最常见的错误之一&#xff0c;通常是由于编写代码时违反了 Python 的语法规则。可能的原因&#xff1a; 忘记在 if、while、for 等语句后写冒号&#xff0c;或者…...

文章评论以及回复评论邮件通知(Go 搭建 qiucode.cn 之八)

要说到评论。无疑是博客应用的灵魂所在了,它也正是站长与博友、博友与博友之间互相交流的桥梁,倘若少了它,博客应用将变得暗淡无关,索然无味,恍如一具躺在床榻上的植物人,终究是无法与周边人言语的。 也正是有了评论,站长在该博客应用所发表的博文,博友才得以通过评论,…...

java面试基础 -- ArrayList 和 LinkedList有什么区别, ArrayList和Vector呢?

目录 基本介绍 有什么不同?? ArrayList的扩容机制 ArrayLIst的基本使用 ArrayList和Vector 基本介绍 还记得我们的java集合框架吗, 我们来复习一下, 如图: 可以看出来 ArrayList和LinkedList 都是具体类, 他们都是接口List的实现类. 但是他们底层的逻辑是不同的, 相信…...

matlab 点云最小二乘拟合空间直线(方法一)

目录 一、算法原理1、空间直线2、最小二乘法拟合二、代码实现三、结果展示四、可视化参考本文由CSDN点云侠原创,原文链接。如果你不是在点云侠的博客中看到该文章,那么此处便是不要脸的爬虫。 一、算法原理 1、空间直线 x...

详解junit

目录 1.概述 2.断言 3.常用注解 3.1.Test 3.2.Before 3.3.After 3.4.BeforeClass 3.5.AfterClass 4.异常测试 5.超时测试 6.参数化测试 1.概述 什么是单元测试&#xff1a; 单元测试&#xff0c;是针对最小的功能单元编写测试代码&#xff0c;在JAVA中最小的功能单…...

Nginx的安装及负载均衡搭建

一.Nginx的安装 1&#xff09;准备安装环境 yum install -y make gcc gcc-c pcre-devel pcre zlib zlib-devel openssl openssl-develPERE PCRE(Perl Compatible Regular Expressions)是一个Perl库&#xff0c;包括 perl 兼容的正则表达式库。 nginx的http模块使用pcre来解…...

JVM学习笔记(一)

1. JVM快速入门 从面试开始&#xff1a; 请谈谈你对JVM 的理解&#xff1f;java8 的虚拟机有什么更新&#xff1f; 什么是OOM &#xff1f;什么是StackOverflowError&#xff1f;有哪些方法分析&#xff1f; JVM 的常用参数调优你知道哪些&#xff1f; 内存快照抓取和MAT分…...

在软件开发中正确使用MySQL日期时间类型的深度解析

在日常软件开发场景中&#xff0c;时间信息的存储是底层且核心的需求。从金融交易的精确记账时间、用户操作的行为日志&#xff0c;到供应链系统的物流节点时间戳&#xff0c;时间数据的准确性直接决定业务逻辑的可靠性。MySQL作为主流关系型数据库&#xff0c;其日期时间类型的…...

Cursor实现用excel数据填充word模版的方法

cursor主页&#xff1a;https://www.cursor.com/ 任务目标&#xff1a;把excel格式的数据里的单元格&#xff0c;按照某一个固定模版填充到word中 文章目录 注意事项逐步生成程序1. 确定格式2. 调试程序 注意事项 直接给一个excel文件和最终呈现的word文件的示例&#xff0c;…...

golang循环变量捕获问题​​

在 Go 语言中&#xff0c;当在循环中启动协程&#xff08;goroutine&#xff09;时&#xff0c;如果在协程闭包中直接引用循环变量&#xff0c;可能会遇到一个常见的陷阱 - ​​循环变量捕获问题​​。让我详细解释一下&#xff1a; 问题背景 看这个代码片段&#xff1a; fo…...

电脑插入多块移动硬盘后经常出现卡顿和蓝屏

当电脑在插入多块移动硬盘后频繁出现卡顿和蓝屏问题时&#xff0c;可能涉及硬件资源冲突、驱动兼容性、供电不足或系统设置等多方面原因。以下是逐步排查和解决方案&#xff1a; 1. 检查电源供电问题 问题原因&#xff1a;多块移动硬盘同时运行可能导致USB接口供电不足&#x…...

在Ubuntu中设置开机自动运行(sudo)指令的指南

在Ubuntu系统中&#xff0c;有时需要在系统启动时自动执行某些命令&#xff0c;特别是需要 sudo权限的指令。为了实现这一功能&#xff0c;可以使用多种方法&#xff0c;包括编写Systemd服务、配置 rc.local文件或使用 cron任务计划。本文将详细介绍这些方法&#xff0c;并提供…...

Ascend NPU上适配Step-Audio模型

1 概述 1.1 简述 Step-Audio 是业界首个集语音理解与生成控制一体化的产品级开源实时语音对话系统&#xff0c;支持多语言对话&#xff08;如 中文&#xff0c;英文&#xff0c;日语&#xff09;&#xff0c;语音情感&#xff08;如 开心&#xff0c;悲伤&#xff09;&#x…...

第 86 场周赛:矩阵中的幻方、钥匙和房间、将数组拆分成斐波那契序列、猜猜这个单词

Q1、[中等] 矩阵中的幻方 1、题目描述 3 x 3 的幻方是一个填充有 从 1 到 9 的不同数字的 3 x 3 矩阵&#xff0c;其中每行&#xff0c;每列以及两条对角线上的各数之和都相等。 给定一个由整数组成的row x col 的 grid&#xff0c;其中有多少个 3 3 的 “幻方” 子矩阵&am…...

【分享】推荐一些办公小工具

1、PDF 在线转换 https://smallpdf.com/cn/pdf-tools 推荐理由&#xff1a;大部分的转换软件需要收费&#xff0c;要么功能不齐全&#xff0c;而开会员又用不了几次浪费钱&#xff0c;借用别人的又不安全。 这个网站它不需要登录或下载安装。而且提供的免费功能就能满足日常…...

Elastic 获得 AWS 教育 ISV 合作伙伴资质,进一步增强教育解决方案产品组合

作者&#xff1a;来自 Elastic Udayasimha Theepireddy (Uday), Brian Bergholm, Marianna Jonsdottir 通过搜索 AI 和云创新推动教育领域的数字化转型。 我们非常高兴地宣布&#xff0c;Elastic 已获得 AWS 教育 ISV 合作伙伴资质。这一重要认证表明&#xff0c;Elastic 作为 …...

AxureRP-Pro-Beta-Setup_114413.exe (6.0.0.2887)

Name&#xff1a;3ddown Serial&#xff1a;FiCGEezgdGoYILo8U/2MFyCWj0jZoJc/sziRRj2/ENvtEq7w1RH97k5MWctqVHA 注册用户名&#xff1a;Axure 序列号&#xff1a;8t3Yk/zu4cX601/seX6wBZgYRVj/lkC2PICCdO4sFKCCLx8mcCnccoylVb40lP...