You cannot shrink the innodb data file (default name is ibdata1
) without deleting it :S .
Using innodb engine you should use innodb_file_per_table=1
To solve you space issue you should:
1) Execute a full database backup: mysqldump -u root -pMyPassword -R --all-databases > full.sql
2) Stop mysql service
3) Add (or change value of) the parameter innodb_file_per_table=1
4) Drop the existing innodb data file (/$mysqldir/ibdata1
)
5) Start mysql service
6) Restore the backup: mylsql -u root -pMyPassword mysql < full.sql
Now the innodb data file will not growth too much anymore, and an optimize table will allow you to shrink the involve table data file since now each table will amnage it's own data file.
Using symbolic links (at least under Linux), it allows you to locate databases on different disks.