【mysql错误 Mac】ERR_WHEN_INSERT_TO_DB\nError:Connection lost: The server closed the connection.

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: ERR_WHEN_INSERT_TO_DB\nError:Connection lost: The server closed the connection.这个是数据库查询报出的错误,所以我们先登录一下数据库,查询看看具体报错

{"code":-1,"error":"ERR_WHEN_INSERT_TO_DB\nError: select count(`open_id`) as `hasUser` from `cSessionInfo` where `open_id` = 'oQPCO4ol5Y_-yL0MnCGxwbiHbSek' - Connection lost: The server closed the connection."}


这个是数据库查询报出的错误,所以我们先登录一下数据库,查询看看具体报错


#登录数据库
~/my-project/server$ mysql -uroot -p
Enter password:
#选择项目数据库名称,我的是cAuth
mysql> use cAuth;
Database changed
#查询选中数据库所有数据表
mysql> show tables;
#查询数据库所有数据表报错
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    8
Current database: cAuth


可以看出查询数据表的时候就报错了,出现错误MySQL server has gone away


这个错误的意思是mysql服务连接不上,运行brew services restart mysql重启一下mysql进程

# 重启 mysql
~/my-project/server$ brew services restart mysql
Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

重启mysql进程之后,再来启动项目试一下是否还报错,现在已经可以了。

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4月前
|
SQL 关系型数据库 MySQL
使用Flink CDC从SQL Server同步数据到MySQL
使用Flink CDC从SQL Server同步数据到MySQL
156 1
|
11天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
22 0
|
2月前
|
关系型数据库 MySQL 数据库
Host 'XXX' is not allowed to connect to this MySQL server 解决方案
Host 'XXX' is not allowed to connect to this MySQL server 解决方案
|
2月前
|
NoSQL 关系型数据库 MySQL
Windows、Linux、Mac安装数据库(mysql、MongoDB、Redis)#0
不同系统下进行MySQL安装、MongoDB安装、Redis安装【2月更文挑战第5天】
445 5
Windows、Linux、Mac安装数据库(mysql、MongoDB、Redis)#0
|
2月前
|
关系型数据库 MySQL 数据安全/隐私保护
【MySQL】 Docker 安装 MySQL8.0(mac)
【MySQL】 Docker 安装 MySQL8.0(mac)
105 0
mac安装homebrew失败:Failed to connect to raw.githubusercontent.com port 443: Connection refused
mac安装homebrew失败:Failed to connect to raw.githubusercontent.com port 443: Connection refused
|
3月前
|
关系型数据库 MySQL 数据库
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Client does not support authentication protocol requested by server; consider upgrading MySQL client
|
4月前
|
关系型数据库 MySQL 数据库
远程连接mysql报错:1130 - Host XXX is not allowed to connect to this MySQL server
远程连接mysql报错:1130 - Host XXX is not allowed to connect to this MySQL server
84 0
|
4月前
|
关系型数据库 MySQL 数据安全/隐私保护
(解决)Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
(解决)Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
39 0
|
4月前
|
关系型数据库 MySQL Linux
MySQL【部署 01】Linux root 用户部署 mysql-5.7.28 及 not allowed to connect to this MySQL server 和中文乱码问题处理
MySQL【部署 01】Linux root 用户部署 mysql-5.7.28 及 not allowed to connect to this MySQL server 和中文乱码问题处理
51 0