{"id":821,"date":"2013-08-22T16:06:05","date_gmt":"2013-08-22T13:06:05","guid":{"rendered":"http:\/\/www.fatihacar.com\/blog\/?p=821"},"modified":"2013-08-22T16:11:05","modified_gmt":"2013-08-22T13:11:05","slug":"mysql-data-file-size-decrease","status":"publish","type":"post","link":"http:\/\/www.fatihacar.com\/blog\/mysql-data-file-size-decrease\/","title":{"rendered":"MySQL Data File Size Decrease"},"content":{"rendered":"<p>If ibdata1 data file size is too big, you can decrease this file. My scenario is that my database have a table and size is 100 GB, I want to take backup and delete all data with decrease datafile size. If I use truncate command, this is not decrease ibdata1 size. I can use backup and drop scenario. I am using MySQL 5.x on Windows Server.<\/p>\n<p><strong>1-Take Backup With Data<\/strong><\/p>\n<blockquote><p>Open Command Prompt (cmd)<br \/>\n> mysqldump.exe -u root -p db_name > E:\\db_backup.sql<\/p><\/blockquote>\n<p><strong>2-Take Metadata Backup<\/strong><\/p>\n<blockquote><p>Open Command Prompt<br \/>\n> mysqldump.exe -u root -p &#8211;no-data db_name > E:\\db_backupmetadata.sql<br \/>\nor<br \/>\n> mysqldump.exe -u root -p -d db_name > E:\\db_backupmetadata.sql<\/p><\/blockquote>\n<p><strong>3-Drop Database<\/strong><\/p>\n<blockquote><p>Open MySQL Client Console<br \/>\nmysql> show databases;<br \/>\nmysql> drop database db_name;<\/p><\/blockquote>\n<p><strong>4-Stop MySQL Service<\/strong><\/p>\n<blockquote><p>Open Services.msc<br \/>\nMySQL servise has to do stop<\/p><\/blockquote>\n<p><strong>5-Delete Data Files<\/strong><\/p>\n<blockquote><p>Open Data Directory<br \/>\nYou can delete ibdata1, ib_logfile0, ib_logfile1 &#8230; start with ib..<br \/>\nThis files will be recreated as automatic by MySQL service when MySQL service start<\/p><\/blockquote>\n<p><strong>6-Start MySQL Service<\/strong><\/p>\n<blockquote><p>Open Services.msc<br \/>\nMySQL servise has to do start<\/p><\/blockquote>\n<p><strong>7-Create Database<\/strong><\/p>\n<blockquote><p>Open MySQL Client Console<br \/>\nmysql> create database db_name;<\/p><\/blockquote>\n<p><strong>8-Restore Metadata From Backup<\/strong><\/p>\n<blockquote><p>Open Command Prompt (cmd)<br \/>\n> mysql.exe -u root -p db_name < E:\\db_backupmetadata.sql<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If ibdata1 data file size is too big, you can decrease this file. My scenario is that my database have a table and size is 100 GB, I want to take backup and delete all data with decrease datafile size. If I use truncate command, this is not decrease ibdata1 size. I can use backup&#8230;<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[43,42],"tags":[14,100,44],"class_list":["post-821","post","type-post","status-publish","format-standard","hentry","category-administration-mysql","category-mysql","tag-database-administration","tag-mysql","tag-mysql-administration"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p39NFI-df","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/comments?post=821"}],"version-history":[{"count":5,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/821\/revisions"}],"predecessor-version":[{"id":826,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/821\/revisions\/826"}],"wp:attachment":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/media?parent=821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/categories?post=821"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/tags?post=821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}