Search code examples
mysqlinnodb

Extending innodb_data_file_path in mysql


Suppose a mysql 5.5 server uses the following configuration for storing innodb data

innodb_data_file_path =  /var/lib/mysql/ibdata:100G;/disk2/mysql/ibdata2:1000M:autoextend

at some point later in time, if the database has already been populated for a while. I wish to add an extra path in this innodb_data_file_path because I'm running out of disks space and a new disk is added. Is this possible? How can it be done? Would something like the following work?

innodb_data_file_path =  /var/lib/mysql/ibdata:100G;/disk2/mysql/ibdata2:XXXG;/disk3/mysql/ibdata3:1000M:autoextend

Solution

  • You have it explained here . When you don't specify path in your innodb_data_home_dir you can put absolute path for innodb_data_file_path, and you can have multiple files there in format file_name:file_size[:autoextend[:max:max_file_size]] separated by semicolon.

    Also, you can add new data file for existing database. Stop mysql, change innodb_data_file_path and start it again.

    One note: if you had configuration something like:

    innodb_data_file_path=/var/lib/mysql/file1:10M:autoextend

    and you want to add new file like

    innodb_data_file_path=/var/lib/mysql/file1:10M;/bigmedia/file2:1800M:autoextend

    it might happen that you will receive errors when you start mysql (not able to initialize InnoDB engine)...error might say something like: "file1 contains xx pages but in my.cnf it says xxx pages" this means that you will have to change size for file1 in my.cnf to it's actuall size (it overgrew it's size specified in config file...which is ok when it is the only file, but mysql expects it to be exactly the specified size and to grow second file when you have second file). It is easy to guess, just 1M increments. So, you will end up with config like:

    innodb_data_file_path=/var/lib/mysql/file1:23M;/bigmedia/file2:1800M:autoextend
    

    Be careful with this and try not to destroy your data :)