Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to resolve MySQL server has gone away errors

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to solve MySQL server has gone away errors. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Enter MySQL

Cmd

Mysql-u username-p password

When we use mysql to import a large file sql, we may report a MySQL server has gone away error. The problem is that the default setting of the max_allowed_packet configuration is too small. We only need to increase the value of this item and then import it again. The purpose of this item is to limit the size of the package received by the mysql server, so if the imported file is too large, it may exceed the value of this setting and cause the import to be unsuccessful! Let's take a look at how to view and set the value of this item.

View the value of max_allowed_packet

Show global variables like 'max_allowed_packet'

+-+ +

| | Variable_name | Value |

+-+ +

| | max_allowed_packet | 4194304 | |

+-+ +

You can see that the size of the item is only 4m by default, and then set the value to 150m (1024m 1024m 150)

Set global max_allowed_packet=157286400

Check the size again at this time

Show global variables like 'max_allowed_packet'

By increasing this value, generally speaking, re-importing sql with a large amount of data should be successful. If you still report an error, just continue to increase it. Please note that the setting on the command line is only valid for the current time, and the default value will be restored after restarting the mysql service. However, permanent validity can be achieved by modifying the configuration file (you can add max_allowed_packet=150M to the configuration file my.cnf). But in fact, we do not often have such a large amount of data import operation, so I feel that through the command to exercise the current configuration effective, there is no need to modify the configuration file.

Thank you for reading! This is the end of the article on "how to solve MySQL server has gone away errors". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report