Get the App
SLTechnology News&Howtos  ›  Database  › 

How to solve the problem of importing large-capacity SQL File data into Mysql

Shulou Source: shulou.com Published: 2022-05-31 11:35:44 10月05日 Update

This article mainly introduces how to solve the problem of Mysql importing large-capacity SQL file data, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

Mysql may have the following two problems when importing sql files:

1. If the sql file is too large, there will be a "MySQL server has gone away" problem

two。 If the sql file data is in Chinese, garbled www.2cto.com will appear.

Resolve the problem:

Problem 1: the MySQL server has gone away problem occurs because the default "max_allowed_packet" variable of mysql is too small.

View current configuration

Show VARIABLES like'% max_allowed_packet%'

The result displayed is:

+-+ +

| | Variable_name | Value |

+-+ +

| | max_allowed_packet | 1048576 | |

+-+ +

The current configuration is 1048576, 1024, 1024, 1024, 1m.

Modify the max_allowed_ packet value:

Method 1: SET GLOBAL max_allowed_packet = 500,1024,1024; (invalid by test)

Method 2: directly modify the configuration file and restart mysql www.2cto.com

Modify the my.ini file in the, and modify the my.cnf file in linux.

C:\ Documents and Settings\ All Users\ Application Data\ MySQL\ MySQL Server 5.5\ my.ini (specified data file directory at installation time)

After restarting mysql, check the modified max_allowed_ packet value

Question 2: specify character set encoding when logging in

Mysql-uroot-P3308-p123456-- default-character-set=utf8 (- P means the specified port number)

Finally, you can successfully import through the source command:

Source E:ydj\ test.sql

Thank you for reading this article carefully. I hope the article "how to solve the problem of importing large-capacity SQL file data into Mysql" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Files questions data articles configuration large capacity large capacity methods success garbled value interests slogans at the same time commands characters character sets more Chinese friends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Shulou Information NVidia Microsoft