报错场景:
处理数据相对较大6000万条的情况下,不知道为什么执行语句过程中出现了
Error2013:2013 lost connection to MYSQL server during query
问题们
第一个问题:Error1175_SQL_SAFE_UPDATES
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect. 0.016 sec
第二个问题:Error Code: 2013. Lost connection to MySQL server during query
update userbehavior set datetime=from_unixtime(time) Error Code: 2013. Lost connection to MySQL server during query 30.015 sec
解决方案:
Error1175问题解决方案:
*#执行语句*
update userbehavior set datetime=from_unixtime(time);
*#报错*
14:20:08 update userbehavior set datetime=from_unixtime(time) Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect. 0.016 sec
*#SQL_SAFE_UPDATES的变量,此值默认为1,确保数据库更新操作的安全性。当我们批量更新数据库时,会出现更新失败的报错情况*
SET SQL_SAFE_UPDATES = 0;
update userbehavior set datetime=from_unixtime(time);
Error2013解决方案:(大名鼎鼎的error2013
Step1: 尝试网上方法修改服务中的参数或者重启服务;
不管用,因为不适用于运行中停止的情况
Step2: 尝试网上方法mysql workbench修改参数 Edit> Preferences> SQL editor> mysql session 改成以下参数
DBMS connection read timeout interval 600 > 0
DBMS connection timeout interval 600 > 1500
运行后仍报错,Duration/Fetch 的值没有超过600sec, 问题不在此处
Step3: 尝试网上方法> ini文件相关
1.有没有ini文件
安装数据库的时候一般会创建一个my.ini文件,没有的话可以自己手动创建,这是mysql的配置文件
一般情况下的存放位置
2.在my.ini中添加skip-name-resolve
不要搞,会报错,新报错的解决方法是#掉skip-name-resolve ; 没意义
3.修改my.ini中参数 修改完成后即可
完整的修改后的my.ini文件在此,仅供参考
# Other default tuning values
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a
# command line shell, e.g.
# mysqld --install MySQLXY