我想导入一个sql dump
mysql -u username mydb < file.sql
当然,我会收到经典的ERROR 2006 (HY000) at line 1701: MySQL server has gone away
消息。没什么大不了的,我知道我需要增加数据包的大小。因此,我编辑了/etc/mysql/mysql.cnf文件,并添加了行max_allowed_packet=64M
。但是,当我尝试启动mysql服务器时,出现错误。
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-01-21 16:27:47 CET; 15s ago
Process: 9151 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 9112 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27620 (code=exited, status=0/SUCCESS)
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 21 16:27:47 aleksandar-pc systemd[1]: Stopped MySQL Community Server.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Start request repeated too quickly.
Jan 21 16:27:47 aleksandar-pc systemd[1]: mysql.service: Failed with result 'exit-code'.
如果我删除了为数据包添加的代码,则服务器可以正常启动。 谁能帮我这个忙,我真的需要导入这个大数据库并且不知道如何解决这个mysql错误。
MySQL版本:适用于Linux(x86_64)的版本14.14 Distrib 5.7.25 Linux:Ubuntu 18.04 LTS
答案 0 :(得分:0)
好吧,我在上面忘记了此[mysqld]
:
[mysqld]
max_allowed_packet=128M