数据库太大了,整个备份导入出问题或者慢,需要将整个库按照表分割(一个表一个sql文件)
环境 win10
工具:python3.7+pycharm
要分割的文件大小:6G,sql文件
import redbname = ''with open('best**.sql', 'r', encoding='utf-8') as f:for i,db in enumerate(f):dbnamea = re.findall('Table structure for (.*)', db)if dbnamea:dbname = dbnamea[0]print('正在写入%s' % dbname)if dbname != '':with open('sqls_datas/{}.sql'.format(dbname), 'a+', encoding='utf-8') as fw:fw.write(db)
print('split sql file done!')