[{"data":1,"prerenderedAt":1272},["ShallowReactive",2],{"article-20201222-mysql-myisam-to-innodb":3},{"article":4,"surround":1261},{"id":5,"title":6,"authorKey":7,"body":8,"codeLinks":1231,"createdAt":1233,"description":1234,"excerpt":1235,"extension":1248,"image":1249,"meta":1250,"navigation":352,"path":1251,"published":1252,"readingTime":349,"revisedAt":1253,"seo":1254,"stem":1255,"tags":1256,"__hash__":1260},"articles\u002Farticles\u002F20201222-mysql-myisam-to-innodb.md","MySQL MyISAM to InnoDB Conversion","philip",{"type":9,"value":10,"toc":1223},"minimark",[11,35,40,43,50,207,213,295,298,392,396,399,428,431,435,438,502,506,509,523,526,604,615,623,626,642,1034,1037,1068,1075,1093,1097,1100,1123,1126,1164,1168,1171,1194,1216,1219],[12,13,14,15,22,23,28,29,34],"p",{},"Back in November 2020, I managed to convert all legacy MyISAM tables to InnoDB on all ",[16,17,21],"a",{"href":18,"rel":19},"https:\u002F\u002Fwww.onlime.ch\u002F",[20],"nofollow","Onlime GmbH"," database servers and customer webservers. MyISAM as legacy storage engine was quite okay-ish on MySQL 5.7 but started to perform really bad on MySQL 8.0. There was simply no reason to keep on using it and honestly, for the last 10 years I did never understand why people still held onto it. I had to find out that a lot of my customers just never heard of any storage engine types, and they didn't even know of any differences between ",[16,24,27],{"href":25,"rel":26},"https:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F8.0\u002Fen\u002Fmyisam-storage-engine.html",[20],"MyISAM"," and ",[16,30,33],{"href":31,"rel":32},"https:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F8.0\u002Fen\u002Finnodb-storage-engine.html",[20],"InnoDB",".",[36,37,39],"h2",{"id":38},"list-all-myisam-tables","List all MyISAM tables",[12,41,42],{},"Before proceeding to the actual task of converting all those shitty MyISAM tables, I would like to present you some queries to find out about MyISAM table existence on your MySQL server.",[12,44,45,46,49],{},"List all ",[47,48,27],"code",{}," tables (+ table size) of all user databases:",[51,52,57],"pre",{"className":53,"code":54,"language":55,"meta":56,"style":56},"language-sql shiki shiki-themes github-light-default github-light-default github-dark-default","SELECT table_schema db, table_name tbl, CAST((IFNULL(data_length, 0) + IFNULL(index_length, 0)) AS SIGNED) size \n    FROM information_schema.TABLES\n        WHERE engine = 'MyISAM' AND table_type = 'BASE TABLE'\n            AND table_schema NOT IN ('information_schema', 'sys', 'performance_schema', 'mysql')\n                ORDER BY table_schema, table_name;\n","sql","",[47,58,59,117,131,158,198],{"__ignoreMap":56},[60,61,64,68,72,76,79,82,85,88,91,94,97,100,102,105,108,111,114],"span",{"class":62,"line":63},"line",1,[60,65,67],{"class":66},"s5nWI","SELECT",[60,69,71],{"class":70},"s_bOF"," table_schema db, table_name tbl, ",[60,73,75],{"class":74},"sDkKp","CAST",[60,77,78],{"class":70},"((",[60,80,81],{"class":66},"IFNULL",[60,83,84],{"class":70},"(data_length, ",[60,86,87],{"class":74},"0",[60,89,90],{"class":70},") ",[60,92,93],{"class":66},"+",[60,95,96],{"class":66}," IFNULL",[60,98,99],{"class":70},"(index_length, ",[60,101,87],{"class":74},[60,103,104],{"class":70},")) ",[60,106,107],{"class":66},"AS",[60,109,110],{"class":70}," SIGNED) ",[60,112,113],{"class":66},"size",[60,115,116],{"class":70}," \n",[60,118,120,123,126,128],{"class":62,"line":119},2,[60,121,122],{"class":66},"    FROM",[60,124,125],{"class":74}," information_schema",[60,127,34],{"class":70},[60,129,130],{"class":74},"TABLES\n",[60,132,134,137,140,143,147,150,153,155],{"class":62,"line":133},3,[60,135,136],{"class":66},"        WHERE",[60,138,139],{"class":70}," engine ",[60,141,142],{"class":66},"=",[60,144,146],{"class":145},"s-BGO"," 'MyISAM'",[60,148,149],{"class":66}," AND",[60,151,152],{"class":70}," table_type ",[60,154,142],{"class":66},[60,156,157],{"class":145}," 'BASE TABLE'\n",[60,159,161,164,167,170,173,176,179,182,185,187,190,192,195],{"class":62,"line":160},4,[60,162,163],{"class":66},"            AND",[60,165,166],{"class":70}," table_schema ",[60,168,169],{"class":66},"NOT",[60,171,172],{"class":66}," IN",[60,174,175],{"class":70}," (",[60,177,178],{"class":145},"'information_schema'",[60,180,181],{"class":70},", ",[60,183,184],{"class":145},"'sys'",[60,186,181],{"class":70},[60,188,189],{"class":145},"'performance_schema'",[60,191,181],{"class":70},[60,193,194],{"class":145},"'mysql'",[60,196,197],{"class":70},")\n",[60,199,201,204],{"class":62,"line":200},5,[60,202,203],{"class":66},"                ORDER BY",[60,205,206],{"class":70}," table_schema, table_name;\n",[12,208,209,210,212],{},"Only list databases with at least one ",[47,211,27],{}," table:",[51,214,216],{"className":53,"code":215,"language":55,"meta":56,"style":56},"SELECT table_schema db FROM information_schema.TABLES\n    WHERE engine = 'MyISAM' AND table_type = 'BASE TABLE'\n        AND table_schema NOT IN ('information_schema', 'sys', 'performance_schema', 'mysql')\n            GROUP BY table_schema ORDER BY table_schema;\n",[47,217,218,234,253,282],{"__ignoreMap":56},[60,219,220,222,225,228,230,232],{"class":62,"line":63},[60,221,67],{"class":66},[60,223,224],{"class":70}," table_schema db ",[60,226,227],{"class":66},"FROM",[60,229,125],{"class":74},[60,231,34],{"class":70},[60,233,130],{"class":74},[60,235,236,239,241,243,245,247,249,251],{"class":62,"line":119},[60,237,238],{"class":66},"    WHERE",[60,240,139],{"class":70},[60,242,142],{"class":66},[60,244,146],{"class":145},[60,246,149],{"class":66},[60,248,152],{"class":70},[60,250,142],{"class":66},[60,252,157],{"class":145},[60,254,255,258,260,262,264,266,268,270,272,274,276,278,280],{"class":62,"line":133},[60,256,257],{"class":66},"        AND",[60,259,166],{"class":70},[60,261,169],{"class":66},[60,263,172],{"class":66},[60,265,175],{"class":70},[60,267,178],{"class":145},[60,269,181],{"class":70},[60,271,184],{"class":145},[60,273,181],{"class":70},[60,275,189],{"class":145},[60,277,181],{"class":70},[60,279,194],{"class":145},[60,281,197],{"class":70},[60,283,284,287,289,292],{"class":62,"line":160},[60,285,286],{"class":66},"            GROUP BY",[60,288,166],{"class":70},[60,290,291],{"class":66},"ORDER BY",[60,293,294],{"class":70}," table_schema;\n",[12,296,297],{},"Or do it all with a nice one-liner for plain output (batch mode), one db name per line:",[51,299,303],{"className":300,"code":301,"language":302,"meta":56,"style":56},"language-bash shiki shiki-themes github-light-default github-light-default github-dark-default","# full list of all tables\n$ mysql -sN -r -e \"SELECT CONCAT(table_schema, '.', table_name) FROM information_schema.TABLES \n    WHERE engine = 'MyISAM' AND table_type = 'BASE TABLE'\n        AND table_schema NOT IN ('information_schema', 'sys', 'performance_schema', 'mysql')\n            ORDER BY table_schema, table_name\"\n\n# only list databases\n$ mysql -sN -r -e \"SELECT table_schema db FROM information_schema.TABLES\n    WHERE engine = 'MyISAM' AND table_type = 'BASE TABLE'\n        AND table_schema NOT IN ('information_schema', 'sys', 'performance_schema', 'mysql')\n            GROUP BY table_schema ORDER BY table_schema\"\n","bash",[47,304,305,311,332,337,342,347,354,360,376,381,386],{"__ignoreMap":56},[60,306,307],{"class":62,"line":63},[60,308,310],{"class":309},"s9BHP","# full list of all tables\n",[60,312,313,317,320,323,326,329],{"class":62,"line":119},[60,314,316],{"class":315},"sQJ0q","$",[60,318,319],{"class":145}," mysql",[60,321,322],{"class":74}," -sN",[60,324,325],{"class":74}," -r",[60,327,328],{"class":74}," -e",[60,330,331],{"class":145}," \"SELECT CONCAT(table_schema, '.', table_name) FROM information_schema.TABLES \n",[60,333,334],{"class":62,"line":133},[60,335,336],{"class":145},"    WHERE engine = 'MyISAM' AND table_type = 'BASE TABLE'\n",[60,338,339],{"class":62,"line":160},[60,340,341],{"class":145},"        AND table_schema NOT IN ('information_schema', 'sys', 'performance_schema', 'mysql')\n",[60,343,344],{"class":62,"line":200},[60,345,346],{"class":145},"            ORDER BY table_schema, table_name\"\n",[60,348,350],{"class":62,"line":349},6,[60,351,353],{"emptyLinePlaceholder":352},true,"\n",[60,355,357],{"class":62,"line":356},7,[60,358,359],{"class":309},"# only list databases\n",[60,361,363,365,367,369,371,373],{"class":62,"line":362},8,[60,364,316],{"class":315},[60,366,319],{"class":145},[60,368,322],{"class":74},[60,370,325],{"class":74},[60,372,328],{"class":74},[60,374,375],{"class":145}," \"SELECT table_schema db FROM information_schema.TABLES\n",[60,377,379],{"class":62,"line":378},9,[60,380,336],{"class":145},[60,382,384],{"class":62,"line":383},10,[60,385,341],{"class":145},[60,387,389],{"class":62,"line":388},11,[60,390,391],{"class":145},"            GROUP BY table_schema ORDER BY table_schema\"\n",[36,393,395],{"id":394},"convert-single-table-to-innodb","Convert single table to InnoDB",[12,397,398],{},"To convert a single table to InnoDB, run:",[51,400,402],{"className":53,"code":401,"language":55,"meta":56,"style":56},"ALTER TABLE `db`.`tablename` ENGINE=InnoDB;\n",[47,403,404],{"__ignoreMap":56},[60,405,406,409,412,415,417,420,423,425],{"class":62,"line":63},[60,407,408],{"class":66},"ALTER",[60,410,411],{"class":66}," TABLE",[60,413,414],{"class":145}," `db`",[60,416,34],{"class":70},[60,418,419],{"class":145},"`tablename`",[60,421,422],{"class":70}," ENGINE",[60,424,142],{"class":66},[60,426,427],{"class":70},"InnoDB;\n",[12,429,430],{},"Run this manually if you just have a bunch of tables to convert. If you have hundreds or thousands of tables to convert, read on.",[36,432,434],{"id":433},"requirements","Requirements",[12,436,437],{},"In my case, I had to convert over 10'000 MyISAM tables (some of which had several GB of data) on multiple MySQL servers. So I sat down and wrote a script that did exactly what I needed with those requirements:",[439,440,441,449,455,467,473,479,489,496],"ul",{},[442,443,444,448],"li",{},[445,446,447],"strong",{},"Loop over all MyISAM tables"," (only user dbs, no system table schemas!)",[442,450,451,454],{},[445,452,453],{},"Limit number of databases"," (no matter how many tables they contain) to convert, so that we could split up conversion and spread the migration over several days to limit risk",[442,456,457,458,463,464],{},"Could be directly written in ",[16,459,462],{"href":460,"rel":461},"https:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Fmysql-shell\u002F8.0\u002Fen\u002F",[20],"MySQL Shell"," but preferably written in ",[445,465,466],{},"Python",[442,468,469,472],{},[445,470,471],{},"Logging",": timestamps (start\u002Fend of conversion of each table), db name, table name",[442,474,475,478],{},[445,476,477],{},"Dumps whole database as backup"," prior to doing conversion.",[442,480,481,484,485,488],{},[445,482,483],{},"Conversion should be done directly"," with ",[47,486,487],{},"ALTER TABLE ... ENGINE=InnoDB"," and not by dumping \u002F loading full DB. (uptime!)",[442,490,491,492,495],{},"Should ",[445,493,494],{},"break on any failure"," (not continuing with next table conversion!) and report to STDOUT",[442,497,498,499],{},"In case of a failure, it should restore data from ",[445,500,501],{},"DB backup dump",[36,503,505],{"id":504},"myisam-to-innodb-converter","MyISAM-to-InnoDB Converter",[12,507,508],{},"I have published this project as it helped me to migrate all customer tables from MyISAM to InnoDB with zero downtime and with near to zero risk:",[439,510,511],{},[442,512,513],{},[445,514,515],{},[16,516,519,520],{"href":517,"rel":518},"https:\u002F\u002Fgitlab.com\u002Fonlime\u002Fmyisam-to-innodb",[20],"MyISAM-to-InnoDB Converter ",[47,521,522],{},"onlime\u002Fmyisam-to-innodb",[12,524,525],{},"Install this project using Python 3 venv:",[51,527,529],{"className":300,"code":528,"language":302,"meta":56,"style":56},"$ git clone git@gitlab.com:onlime\u002Fmyisam-to-innodb.git\n$ cd myisam-to-innodbd\n$ python3 -m venv venv\n$ . venv\u002Fbin\u002Factivate\n(venv)$ pip install -r requirements.txt\n",[47,530,531,544,554,570,580],{"__ignoreMap":56},[60,532,533,535,538,541],{"class":62,"line":63},[60,534,316],{"class":315},[60,536,537],{"class":145}," git",[60,539,540],{"class":145}," clone",[60,542,543],{"class":145}," git@gitlab.com:onlime\u002Fmyisam-to-innodb.git\n",[60,545,546,548,551],{"class":62,"line":119},[60,547,316],{"class":315},[60,549,550],{"class":145}," cd",[60,552,553],{"class":145}," myisam-to-innodbd\n",[60,555,556,558,561,564,567],{"class":62,"line":133},[60,557,316],{"class":315},[60,559,560],{"class":145}," python3",[60,562,563],{"class":74}," -m",[60,565,566],{"class":145}," venv",[60,568,569],{"class":145}," venv\n",[60,571,572,574,577],{"class":62,"line":160},[60,573,316],{"class":315},[60,575,576],{"class":145}," .",[60,578,579],{"class":145}," venv\u002Fbin\u002Factivate\n",[60,581,582,585,588,591,593,596,599,601],{"class":62,"line":200},[60,583,584],{"class":70},"(",[60,586,587],{"class":315},"venv",[60,589,590],{"class":70},")",[60,592,316],{"class":315},[60,594,595],{"class":145}," pip",[60,597,598],{"class":145}," install",[60,600,325],{"class":74},[60,602,603],{"class":145}," requirements.txt\n",[12,605,606,607,610,611,614],{},"MyISAM-to-InnoDB consists of a single script ",[47,608,609],{},"convert.py"," which is pretty powerful, check ",[47,612,613],{},"convert.py --help"," for help:",[51,616,621],{"className":617,"code":619,"language":620},[618],"language-text","usage: convert.py [-h] [--dbpattern DBPATTERN] [--skip-dbs SKIP_DBS] [--limit LIMIT] [--not-before NOT_BEFORE]\n                  [--login-path LOGIN_PATH] [--backup-dir BACKUP_DIR] [--dryrun] [--logdir LOGDIR] [--verbose] [--debug]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --dbpattern DBPATTERN\n                        database pattern to limit search\n  --skip-dbs SKIP_DBS   databases to ignore (comma separated)\n  --limit LIMIT         Limit number of databases (Default: 0 \u002F unlimited)\n  --not-before NOT_BEFORE\n                        Limit tables by age (update_time)\n  --login-path LOGIN_PATH\n                        login_path for authentication (Default: client)\n  --backup-dir BACKUP_DIR\n                        Path for mysqldump backups (Default: backups)\n  --dryrun, --dry-run   Don't convert anything, just output MyISAM tables\n  --logdir LOGDIR       Logdir path (Default: logs)\n  --verbose             Also print all log entries\n  --debug               Enable debug mode\n","text",[47,622,619],{"__ignoreMap":56},[12,624,625],{},"Usage examples:",[627,628,629],"blockquote",{},[12,630,631,634,635,638,639,641],{},[445,632,633],{},"WARNING:"," Do not try this at home! I have added ",[47,636,637],{},"--dryrun"," to every command, so that it won't touch your existing data. Once you are sure what the command does, run it without the ",[47,640,637],{}," flag.",[51,643,645],{"className":300,"code":644,"language":302,"meta":56,"style":56},"$ cd \u003CPROJECT_DIR>\n$ . venv\u002Fbin\u002Factivate\n\n# Convert all user tables\n(venv)$ .\u002Fconvert.py --dryrun\n\n# Convert all tables of a single database\n(venv)$ .\u002Fconvert.py --dbpattern=my_db1 --dryrun\n\n# Convert all tables of a single database\n(venv)$ .\u002Fconvert.py --dbpattern=dbname --dryrun\n\n# Convert all tables of all databases by pattern\n(venv)$ .\u002Fconvert.py --dbpattern='my_db%' --dryrun\n\n# Convert all tables of all databases by pattern and write backups to some external dir\n(venv)$ .\u002Fconvert.py --dbpattern='my_db%' --backup-dir=\u002Fbackups\u002Fmyisam-dumps --dryrun\n\n# Convert all tables of all databases but exclude some single dbs (comma separated list)\n(venv)$ .\u002Fconvert.py --skip-dbs='my_db1,my_db2' --dryrun\n# or even combine such excludes with a db pattern\n(venv)$ .\u002Fconvert.py --dbpattern='my_db%' --skip-dbs='my_db1,my_db2' --dryrun\n\n# Convert all tables and output loglines (in addition to application.log)\n(venv)$ .\u002Fconvert.py --dryrun --verbose\n\n# Convert all tables, limited by the next 10 databases with MyISAM tables\n(venv)$ .\u002Fconvert.py --limit=10 --dryrun --verbose\n\n# Convert all tables, limited by the next 10 databases with MyISAM tables, \n# also reporting debug messages (e.g. creation of single table backup dumps) on STDOUT\n(venv)$ .\u002Fconvert.py --limit=10 --dryrun --verbose --debug\n\n# Finally, you can limit MyISAM table lookup by age. As we cannot count on create_time, we\n# only limit by update_time from information_schema.TABLES\n# This is only used for a very special use case if you want to exclude really old MyISAM \n# tables which might have been created\u002Fused prior a MySQL 5.7 upgrade, avoiding problems like:\n# https:\u002F\u002Fbugs.mysql.com\u002Fbug.php?id=99791\n(venv)$ .\u002Fconvert.py --not-before='2018-01-01' --dryrun --verbose\n",[47,646,647,665,673,677,682,698,702,707,724,728,732,749,754,760,781,786,792,814,819,825,846,852,875,880,886,905,910,916,936,941,947,953,976,981,987,993,999,1005,1011],{"__ignoreMap":56},[60,648,649,651,653,656,659,662],{"class":62,"line":63},[60,650,316],{"class":315},[60,652,550],{"class":145},[60,654,655],{"class":66}," \u003C",[60,657,658],{"class":145},"PROJECT_DI",[60,660,661],{"class":70},"R",[60,663,664],{"class":66},">\n",[60,666,667,669,671],{"class":62,"line":119},[60,668,316],{"class":315},[60,670,576],{"class":145},[60,672,579],{"class":145},[60,674,675],{"class":62,"line":133},[60,676,353],{"emptyLinePlaceholder":352},[60,678,679],{"class":62,"line":160},[60,680,681],{"class":309},"# Convert all user tables\n",[60,683,684,686,688,690,692,695],{"class":62,"line":200},[60,685,584],{"class":70},[60,687,587],{"class":315},[60,689,590],{"class":70},[60,691,316],{"class":315},[60,693,694],{"class":145}," .\u002Fconvert.py",[60,696,697],{"class":74}," --dryrun\n",[60,699,700],{"class":62,"line":349},[60,701,353],{"emptyLinePlaceholder":352},[60,703,704],{"class":62,"line":356},[60,705,706],{"class":309},"# Convert all tables of a single database\n",[60,708,709,711,713,715,717,719,722],{"class":62,"line":362},[60,710,584],{"class":70},[60,712,587],{"class":315},[60,714,590],{"class":70},[60,716,316],{"class":315},[60,718,694],{"class":145},[60,720,721],{"class":74}," --dbpattern=my_db1",[60,723,697],{"class":74},[60,725,726],{"class":62,"line":378},[60,727,353],{"emptyLinePlaceholder":352},[60,729,730],{"class":62,"line":383},[60,731,706],{"class":309},[60,733,734,736,738,740,742,744,747],{"class":62,"line":388},[60,735,584],{"class":70},[60,737,587],{"class":315},[60,739,590],{"class":70},[60,741,316],{"class":315},[60,743,694],{"class":145},[60,745,746],{"class":74}," --dbpattern=dbname",[60,748,697],{"class":74},[60,750,752],{"class":62,"line":751},12,[60,753,353],{"emptyLinePlaceholder":352},[60,755,757],{"class":62,"line":756},13,[60,758,759],{"class":309},"# Convert all tables of all databases by pattern\n",[60,761,763,765,767,769,771,773,776,779],{"class":62,"line":762},14,[60,764,584],{"class":70},[60,766,587],{"class":315},[60,768,590],{"class":70},[60,770,316],{"class":315},[60,772,694],{"class":145},[60,774,775],{"class":74}," --dbpattern=",[60,777,778],{"class":145},"'my_db%'",[60,780,697],{"class":74},[60,782,784],{"class":62,"line":783},15,[60,785,353],{"emptyLinePlaceholder":352},[60,787,789],{"class":62,"line":788},16,[60,790,791],{"class":309},"# Convert all tables of all databases by pattern and write backups to some external dir\n",[60,793,795,797,799,801,803,805,807,809,812],{"class":62,"line":794},17,[60,796,584],{"class":70},[60,798,587],{"class":315},[60,800,590],{"class":70},[60,802,316],{"class":315},[60,804,694],{"class":145},[60,806,775],{"class":74},[60,808,778],{"class":145},[60,810,811],{"class":74}," --backup-dir=\u002Fbackups\u002Fmyisam-dumps",[60,813,697],{"class":74},[60,815,817],{"class":62,"line":816},18,[60,818,353],{"emptyLinePlaceholder":352},[60,820,822],{"class":62,"line":821},19,[60,823,824],{"class":309},"# Convert all tables of all databases but exclude some single dbs (comma separated list)\n",[60,826,828,830,832,834,836,838,841,844],{"class":62,"line":827},20,[60,829,584],{"class":70},[60,831,587],{"class":315},[60,833,590],{"class":70},[60,835,316],{"class":315},[60,837,694],{"class":145},[60,839,840],{"class":74}," --skip-dbs=",[60,842,843],{"class":145},"'my_db1,my_db2'",[60,845,697],{"class":74},[60,847,849],{"class":62,"line":848},21,[60,850,851],{"class":309},"# or even combine such excludes with a db pattern\n",[60,853,855,857,859,861,863,865,867,869,871,873],{"class":62,"line":854},22,[60,856,584],{"class":70},[60,858,587],{"class":315},[60,860,590],{"class":70},[60,862,316],{"class":315},[60,864,694],{"class":145},[60,866,775],{"class":74},[60,868,778],{"class":145},[60,870,840],{"class":74},[60,872,843],{"class":145},[60,874,697],{"class":74},[60,876,878],{"class":62,"line":877},23,[60,879,353],{"emptyLinePlaceholder":352},[60,881,883],{"class":62,"line":882},24,[60,884,885],{"class":309},"# Convert all tables and output loglines (in addition to application.log)\n",[60,887,889,891,893,895,897,899,902],{"class":62,"line":888},25,[60,890,584],{"class":70},[60,892,587],{"class":315},[60,894,590],{"class":70},[60,896,316],{"class":315},[60,898,694],{"class":145},[60,900,901],{"class":74}," --dryrun",[60,903,904],{"class":74}," --verbose\n",[60,906,908],{"class":62,"line":907},26,[60,909,353],{"emptyLinePlaceholder":352},[60,911,913],{"class":62,"line":912},27,[60,914,915],{"class":309},"# Convert all tables, limited by the next 10 databases with MyISAM tables\n",[60,917,919,921,923,925,927,929,932,934],{"class":62,"line":918},28,[60,920,584],{"class":70},[60,922,587],{"class":315},[60,924,590],{"class":70},[60,926,316],{"class":315},[60,928,694],{"class":145},[60,930,931],{"class":74}," --limit=10",[60,933,901],{"class":74},[60,935,904],{"class":74},[60,937,939],{"class":62,"line":938},29,[60,940,353],{"emptyLinePlaceholder":352},[60,942,944],{"class":62,"line":943},30,[60,945,946],{"class":309},"# Convert all tables, limited by the next 10 databases with MyISAM tables, \n",[60,948,950],{"class":62,"line":949},31,[60,951,952],{"class":309},"# also reporting debug messages (e.g. creation of single table backup dumps) on STDOUT\n",[60,954,956,958,960,962,964,966,968,970,973],{"class":62,"line":955},32,[60,957,584],{"class":70},[60,959,587],{"class":315},[60,961,590],{"class":70},[60,963,316],{"class":315},[60,965,694],{"class":145},[60,967,931],{"class":74},[60,969,901],{"class":74},[60,971,972],{"class":74}," --verbose",[60,974,975],{"class":74}," --debug\n",[60,977,979],{"class":62,"line":978},33,[60,980,353],{"emptyLinePlaceholder":352},[60,982,984],{"class":62,"line":983},34,[60,985,986],{"class":309},"# Finally, you can limit MyISAM table lookup by age. As we cannot count on create_time, we\n",[60,988,990],{"class":62,"line":989},35,[60,991,992],{"class":309},"# only limit by update_time from information_schema.TABLES\n",[60,994,996],{"class":62,"line":995},36,[60,997,998],{"class":309},"# This is only used for a very special use case if you want to exclude really old MyISAM \n",[60,1000,1002],{"class":62,"line":1001},37,[60,1003,1004],{"class":309},"# tables which might have been created\u002Fused prior a MySQL 5.7 upgrade, avoiding problems like:\n",[60,1006,1008],{"class":62,"line":1007},38,[60,1009,1010],{"class":309},"# https:\u002F\u002Fbugs.mysql.com\u002Fbug.php?id=99791\n",[60,1012,1014,1016,1018,1020,1022,1024,1027,1030,1032],{"class":62,"line":1013},39,[60,1015,584],{"class":70},[60,1017,587],{"class":315},[60,1019,590],{"class":70},[60,1021,316],{"class":315},[60,1023,694],{"class":145},[60,1025,1026],{"class":74}," --not-before=",[60,1028,1029],{"class":145},"'2018-01-01'",[60,1031,901],{"class":74},[60,1033,904],{"class":74},[12,1035,1036],{},"Or run it in a one-liner (without entering the venv):",[51,1038,1040],{"className":300,"code":1039,"language":302,"meta":56,"style":56},"$ cd \u003CPROJECT_DIR> && venv\u002Fbin\u002Fpython convert.py --dryrun\n",[47,1041,1042],{"__ignoreMap":56},[60,1043,1044,1046,1048,1050,1052,1054,1057,1060,1063,1066],{"class":62,"line":63},[60,1045,316],{"class":315},[60,1047,550],{"class":145},[60,1049,655],{"class":66},[60,1051,658],{"class":145},[60,1053,661],{"class":70},[60,1055,1056],{"class":66},">",[60,1058,1059],{"class":70}," && ",[60,1061,1062],{"class":315},"venv\u002Fbin\u002Fpython",[60,1064,1065],{"class":145}," convert.py",[60,1067,697],{"class":74},[12,1069,1070,1071,1074],{},"If you did not specify ",[47,1072,1073],{},"--verbose",", you might want to monitor the log:",[51,1076,1078],{"className":300,"code":1077,"language":302,"meta":56,"style":56},"$ tail -f logs\u002Fapplication.log\n",[47,1079,1080],{"__ignoreMap":56},[60,1081,1082,1084,1087,1090],{"class":62,"line":63},[60,1083,316],{"class":315},[60,1085,1086],{"class":145}," tail",[60,1088,1089],{"class":74}," -f",[60,1091,1092],{"class":145}," logs\u002Fapplication.log\n",[36,1094,1096],{"id":1095},"run-it-in-a-cronjob","Run it in a cronjob",[12,1098,1099],{},"If running this in a cronjob, ensure the following:",[439,1101,1102,1117],{},[442,1103,1104,1105,1108,1109,1112,1113,1116],{},"The user needs to have access to the right ",[47,1106,1107],{},"--login-path"," which is stored in his ",[47,1110,1111],{},"~\u002F.mylogin.cnf",". Usually this will be ",[47,1114,1115],{},"root",", as we don't want to store MySQL root credentials in any regular system user environment.",[442,1118,1119,1120,1122],{},"The ",[47,1121,609],{}," script needs to run inside your project's venv",[12,1124,1125],{},"example of a nightly cronjob at 04:15AM, only converting MyISAM tables of 10 databases:",[51,1127,1129],{"className":300,"code":1128,"language":302,"meta":56,"style":56},"15 4    * * *   cd PROJECT_DIR && venv\u002Fbin\u002Fpython convert.py --limit=10 --backup-dir=\u002Fbackups\u002Fmyisam-dumps\n",[47,1130,1131],{"__ignoreMap":56},[60,1132,1133,1136,1139,1142,1145,1147,1150,1153,1155,1157,1159,1161],{"class":62,"line":63},[60,1134,1135],{"class":315},"15",[60,1137,1138],{"class":74}," 4",[60,1140,1141],{"class":74},"    *",[60,1143,1144],{"class":74}," *",[60,1146,1144],{"class":74},[60,1148,1149],{"class":145},"   cd",[60,1151,1152],{"class":145}," PROJECT_DIR",[60,1154,1059],{"class":70},[60,1156,1062],{"class":315},[60,1158,1065],{"class":145},[60,1160,931],{"class":74},[60,1162,1163],{"class":74}," --backup-dir=\u002Fbackups\u002Fmyisam-dumps\n",[36,1165,1167],{"id":1166},"disable-myisam","Disable MyISAM",[12,1169,1170],{},"After having successfully converted all MyISAM tables to InnoDB (check with above queries), it's time to disable MyISAM for good!",[12,1172,1173,1174,1179,1180,1183,1184,1187,1188,1193],{},"Put those storage engines into ",[16,1175,1178],{"href":1176,"rel":1177},"https:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F8.0\u002Fen\u002Fserver-system-variables.html#sysvar_disabled_storage_engines",[20],"disabled_storage_engines"," in your MySQL configuration (",[47,1181,1182],{},"\u002Fetc\u002Fmysql\u002Fmy.cnf"," or ",[47,1185,1186],{},"\u002Fetc\u002Fmysql\u002Fmysql.conf.d\u002Fmysqld.cnf "," on a Debian Linux \u002F ",[16,1189,1192],{"href":1190,"rel":1191},"https:\u002F\u002Fwww.percona.com\u002Fsoftware\u002Fmysql-database\u002Fpercona-server",[20],"Percona Server for MySQL","):",[51,1195,1199],{"className":1196,"code":1197,"language":1198,"meta":56,"style":56},"language-ini shiki shiki-themes github-light-default github-light-default github-dark-default","[mysqld]\ndisabled_storage_engines = \"MyISAM,MERGE\"\n","ini",[47,1200,1201,1206],{"__ignoreMap":56},[60,1202,1203],{"class":62,"line":63},[60,1204,1205],{"class":315},"[mysqld]\n",[60,1207,1208,1210,1213],{"class":62,"line":119},[60,1209,1178],{"class":66},[60,1211,1212],{"class":70}," = ",[60,1214,1215],{"class":145},"\"MyISAM,MERGE\"\n",[12,1217,1218],{},"Restart MySQL and say goodbye to MyISAM forever!",[1220,1221,1222],"style",{},"html pre.shiki code .s5nWI, html code.shiki .s5nWI{--shiki-light:#CF222E;--shiki-default:#CF222E;--shiki-dark:#FF7B72}html pre.shiki code .s_bOF, html code.shiki .s_bOF{--shiki-light:#1F2328;--shiki-default:#1F2328;--shiki-dark:#E6EDF3}html pre.shiki code .sDkKp, html code.shiki .sDkKp{--shiki-light:#0550AE;--shiki-default:#0550AE;--shiki-dark:#79C0FF}html pre.shiki code .s-BGO, html code.shiki .s-BGO{--shiki-light:#0A3069;--shiki-default:#0A3069;--shiki-dark:#A5D6FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s9BHP, html code.shiki .s9BHP{--shiki-light:#6E7781;--shiki-default:#6E7781;--shiki-dark:#8B949E}html pre.shiki code .sQJ0q, html code.shiki .sQJ0q{--shiki-light:#953800;--shiki-default:#953800;--shiki-dark:#FFA657}",{"title":56,"searchDepth":119,"depth":133,"links":1224},[1225,1226,1227,1228,1229,1230],{"id":38,"depth":119,"text":39},{"id":394,"depth":119,"text":395},{"id":433,"depth":119,"text":434},{"id":504,"depth":119,"text":505},{"id":1095,"depth":119,"text":1096},{"id":1166,"depth":119,"text":1167},[1232],{"link":517,"desc":522},"2020-12-22","How to convert thousands of MySQL tables from MyISAM to InnoDB.",{"type":9,"value":1236},[1237],[12,1238,14,1239,22,1242,28,1245,34],{},[16,1240,21],{"href":18,"rel":1241},[20],[16,1243,27],{"href":25,"rel":1244},[20],[16,1246,33],{"href":31,"rel":1247},[20],"md","\u002Fimages\u002Fcovers\u002Fmysql-storage-engines.jpg",{},"\u002Farticles\u002F20201222-mysql-myisam-to-innodb",false,null,{"title":6,"description":1234},"articles\u002F20201222-mysql-myisam-to-innodb",[1257,1258,1259],"mysql","python","sysadmin","VGUgNgvDTtfyK-GL8bUDxsyJZOW5OXmOwPIc9tTT8HQ",[1262,1267],{"title":1263,"path":1264,"stem":1265,"createdAt":1266,"children":-1},"Automated Bayesian Spam\u002FHam Training with Rspamd","\u002Farticles\u002F20200311-rspamd-trainer-bayes","articles\u002F20200311-rspamd-trainer-bayes","2020-03-11",{"title":1268,"path":1269,"stem":1270,"createdAt":1271,"children":-1},"Block email forwarding spam with Rspamd","\u002Farticles\u002F20210416-rspamd-forwarding-spam","articles\u002F20210416-rspamd-forwarding-spam","2021-04-16",1794961391451]