I'm trying to rename a large database by creating a new database and then renaming the tables from the old one. I'm only loading/renaming 3 versions of the database (staging, production, archive) so at max it should be 18GBish of data. But my ibdata1 file has filled (30GB) and my overflow ibdata2 has grown to my max specified size (6GB). This results in errors during database loads where it says 'xyz table is full' and the load fails.
It was my understanding that you can't shrink the ibdata files, and doing drop's, etc won't free up space but they will remove old data when you NEED the space. As I can't imagine why my three 6GB databases are using 30GB of ibdata storage, let along the 6GB of overflow I don't understand what's going wrong.
Previously, I was just using 1 database -- dropping it when I started the load. But this means the replicated site (no I can't use master/slave -- we don't control the master and only have access to the db dumps) is down for a long time while it loads -- and if something fails I have no recourse but to fix the problem immediately (hence why the load into a staging area first is preferable). I did not run into this issue until I started doing the database renames so I'm sure the issue is here but I don't know why. Here is the relevant chunk of the script I'm using to do the renames.
$MYSQLCONN -e "DROP DATABASE $NEWDB"
$MYSQLCONN -e "CREATE DATABASE $NEWDB"
params=`$MYSQLCONN --skip-column-names -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='$OLDDB'"`
for name in $params; do
$MYSQLCONN -e "RENAME TABLE $OLDDB.$name to $NEWDB.$name";
done;
It was my understanding that you can't shrink the ibdata files, and doing drop's, etc won't free up space but they will remove old data when you NEED the space. As I can't imagine why my three 6GB databases are using 30GB of ibdata storage, let along the 6GB of overflow I don't understand what's going wrong.
Previously, I was just using 1 database -- dropping it when I started the load. But this means the replicated site (no I can't use master/slave -- we don't control the master and only have access to the db dumps) is down for a long time while it loads -- and if something fails I have no recourse but to fix the problem immediately (hence why the load into a staging area first is preferable). I did not run into this issue until I started doing the database renames so I'm sure the issue is here but I don't know why. Here is the relevant chunk of the script I'm using to do the renames.
$MYSQLCONN -e "DROP DATABASE $NEWDB"
$MYSQLCONN -e "CREATE DATABASE $NEWDB"
params=`$MYSQLCONN --skip-column-names -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='$OLDDB'"`
for name in $params; do
$MYSQLCONN -e "RENAME TABLE $OLDDB.$name to $NEWDB.$name";
done;