1 Matlab 通过 odbc 数据源连接 mysql 数据库,并解决数据中文乱码
upgraded mysql odbc connector: https://dev.mysql.com/downloads/file/?id=472464
-
control panel - data source(odbc) - user DSN - add - mysql odbc 5.3 Unicode driver
*** on 'mysql conector/odbc data source configuration' panel - details, remember to:
(1) check 'interactive client'
(2) set 'character set': GBK
- in MATLAB:
slCharacterEncoding('GBK);
conn = database(datasource, username, pswd);
curs = exec(conn, querystatement);
curs = fetch(curs, 5);
data = curs.data
- bingo.
利用matlab DataExplorer 打开数据库,可以发现中文显示正常
参考文献:
解决方法:金鸟儿 https://blog.csdn.net/goyyue/article/details/78835635
字符编码介绍见:https://www.jianshu.com/p/c23f3ea5443d
2 解决 sql文件太大无法导入的问题
如@kakuilan 所说, 在my.cnf
中把max_allowed_packet
改大点即可.
我在的环境是docker MySQL5.7,
使用mysql命令行输入:
set global max_allowed_packet = 200*1024*1024
show VARIABLES LIKE '%max_allowed_packet%';
参考文献:
解决方法见:https://github.com/kakuilan/china_area_mysql/issues/11