MySQL ibdata1 file is pretty big: recommend stackexchange post?

Posted on 2014-11-15
Last Modified: 2014-11-18

I have an earlier related posting but different. The /var/lib/mysql/ibdata1 file is pretty big:
781056  /var/lib/mysql/ibdata1

I read this posting to on how to possibly resolve it:

Is this recommended? I'd like to avoid deleting any databases though.

Father God bless<><

I ran this to see my large files.

du -a /var | sort -n -r | head -n 10

3048880 /var
1396040 /var/log
1381472 /var/lib
1140736 /var/log/btmp
928720  /var/lib/mysql
781056  /var/lib/mysql/ibdata1
210048  /var/log/chkservd.log
202580  /var/cpanel
118796  /var/cpanel/perl
118784  /var/cpanel/perl/easy
root@ip-184-168-116-73 [/var/lib/mysql]# cd /var/lib/mysql
root@ip-184-168-116-73 [/var/lib/mysql]# ls -al
total 901172
drwxr-x--x 15 mysql mysql      4096 Nov 15 17:43 ./
drwxr-xr-x 33 root  root       4096 Jul 30 15:43 ../
-rw-r--r--  1 mysql mysql      3142 Jul 30 14:39 RPM_UPGRADE_HISTORY
-rw-r--r--  1 mysql mysql       524 Jul 30 14:39 RPM_UPGRADE_MARKER-LAST
-rw-rw----  1 mysql mysql        56 Jul 30 05:29 auto.cnf
drwx------  2 mysql mysql      4096 Oct 27  2012 cphulkd/
drwx------  2 mysql mysql      4096 Nov 13 08:27 emailmar_iem/
drwx------  2 mysql mysql      4096 Aug 27  2011 emailmar_templates/
drwx------  2 mysql mysql      4096 Nov  1 05:32 eximstats/
drwx------  2 mysql mysql     12288 Mar  6  2014 horde/
-rw-rw----  1 mysql mysql  50331648 Nov 15 17:49 ib_logfile0
-rw-rw----  1 mysql mysql  50331648 Nov 13 12:21 ib_logfile1
-rw-rw----  1 mysql mysql 799014912 Nov 15 17:49 ibdata1
-rw-rw----  1 mysql mysql    499659 Jul 30 16:04 ip-184-168-116-73-slow.log
-rw-rw----  1 mysql mysql    895837 Nov 15 17:49
-rw-rw----  1 mysql mysql         5 Nov 15 17:38
drwx------  2 mysql mysql      4096 Jul 13  2011 leechprotect/
drwx------  2 mysql mysql      4096 Apr  5  2012 logaholicDB_ip_184_168_116_73/
drwx------  2 mysql mysql      4096 Jul 31 01:44 modsec/
drwx--x--x  2 mysql mysql      4096 Jul 30 06:15 mysql/
-rw-rw----  1 mysql mysql  16436304 Nov 15 15:00 mysql-bin.000049
-rw-rw----  1 mysql mysql   4079207 Nov 15 17:38 mysql-bin.000050
-rw-rw----  1 mysql mysql    178659 Nov 15 17:49 mysql-bin.000051
-rw-rw----  1 mysql mysql        57 Nov 15 17:42 mysql-bin.index
srwxrwxrwx  1 mysql mysql         0 Nov 15 17:38 mysql.sock=
-rw-r--r--  1 mysql mysql         6 Jul 30 06:15 mysql_upgrade_info
drwx------  2 mysql mysql      4096 Jul 14 18:21 myultrat_questionnaire/
-rw-------  1 mysql root        953 Jul 30 15:42 nohup.out
drwx------  2 mysql mysql      4096 Jul 30 06:15 performance_schema/
drwx------  2 mysql mysql      4096 Aug  5 02:45 roundcube/
drwx------  2 mysql mysql      4096 Jul 31 02:37 whmxfer/
Question by:Victor Kimura
LVL 24

Accepted Solution

mankowitz earned 125 total points
ID: 40445127
This is a really big and really old problem. It has been around for years. The recommended solution is (unfortunately) still the best. Check this out:
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40445139
'Big' is relative.  Do you have 90% data in your 781MB or 10%?  If it is 90% you will waste a lot of time trying to shrink it.

Author Comment

by:Victor Kimura
ID: 40445152
How do I find out how much space is in that 781MB file? Is there a MySQL command that I can use. All the databases are in that file though so I would assume (I don't know if it's safe to assume though) that the 781MB file is composed mostly of my entire databases aggregated together. But is there some command line that I enter to quickly find out?
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

LVL 83

Expert Comment

by:Dave Baldwin
ID: 40445160
I don't know yet.  There should be something but I haven't found it yet.
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40445162
On this page , it says you can get the amount of free space in a single table but not in the database or the server file 'ibdata'.

Author Comment

by:Victor Kimura
ID: 40445317
Hmmm...I guess Danny Beckett's solution and Max Webster's reply is probably a good option. Max says the config option in the my.cnf file:

If you use the configuration option innodb_file_per_table, you create multiple tablespaces. That is, MySQL creates separate files for each table instead of one shared file. These separate files a stored in the directory of the database, and they are deleted when you delete this database. This should remove the need to shrink/purge ibdata files in your case

I guess this has to be done manually every so often then?
LVL 19

Assisted Solution

jools earned 125 total points
ID: 40451348
We used the following to get an idea of db size, I've no idea where it originally came from but we've been using it for a few months now;

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"  FROM information_schema.TABLES GROUP BY table_schema;

Open in new window

Just for info and all that

Author Closing Comment

by:Victor Kimura
ID: 40451424
Ok, thank you, fellas. You were helpful. =)

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AWS ELB 5 77
running code or pseudo code of table structure 5 25
fedora linux on laptop - setup sendmail - or some kind of email 5 44
bash file 10 37
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question