1.Linux下比較簡單,在/etc/my.cnf中修改就可以了
2.Windows下可以修改my.ini,但位置比較難找。
MySQL bugs里有人這么回答:
Alright... Using the newest MySQL installer (5.6.11), the following command line parameter is automatically added to the service and the command line client start menu shortcut: --defaults-file=C:\ProgramData\MySQL\MySQL Server 5.6\my.ini But if I try to manually use any of the mysql binary tools (mysqlcheck.exe, mysqldump.exe, ...), they still try to load the my.ini from: "Default options are read from the following files in the given order: C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf c:\Program Files\MySQL\M ySQL Server 5.6\my.ini c:\Program Files\MySQL\MySQL Server 5.6\my.cnf" So Maybe it's time to add ProgramData\MySQL to the list? :) (or even give it precedence over all others)
這里有一個方法
Win+R 運行 "services.msc"
找到mysql的服務,雙擊打開,可以看到執行參數

3. 還有一種方法,在控制台執行:set global max_allowed_packet=100000000;
重啟動mysql丟失,注意要啟動新的命令行才能生效。
4. mysql 自定義函數,出現
Error Code: 1366 Incorrect string value: '\xE4\xBF\xA1\xE6\x81\xAF...
除了返回字段utf8外,還需要declare的字段也要是utf8才行
-- --------------------------------------------------------------------------------
-- get the full department path
-- Author:zhouyu
-- Data:2014.1.9
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `fn_getFullDeptPath`
(in_dept_id varchar(32)) RETURNS varchar(800) CHARSET utf8
BEGIN
declare deptPath varchar(800) charset utf8;
declare deptName varchar(200) charset utf8;
declare pDeptId varchar(32);
set deptPath = '';
-- 不支持遞歸,往下寫4級吧
-- 第一層
select department_name,parent_department_id into deptName, pDeptId from tb_c_department where
department_id=in_dept_id;
if pDeptId = '0' then
set deptPath = deptName;
else
-- 第二層
set deptPath = deptName;
select department_name,parent_department_id into deptName, pDeptId from tb_c_department where
department_id=pDeptId;
if pDeptId = '0' then
set deptPath = concat(deptName,'-',deptPath);
else
-- 第三層
set deptPath = concat(deptName,'-',deptPath);
select department_name,parent_department_id into deptName, pDeptId from tb_c_department where
department_id=pDeptId;
if pDeptId = '0' then
set deptPath = concat(deptName,'-',deptPath);
else
-- 第四層
set deptPath = concat(deptName,'-',deptPath);
select department_name,parent_department_id into deptName, pDeptId from tb_c_department where
department_id=pDeptId;
if pDeptId = '0' then
set deptPath = concat(deptName,'-',deptPath);
end if;
end if;
end if;
end if;
return deptPath;
END
