1. Home
  2. Technology
  3. MySQL
  4. Move MySQL Database File Storage Location to Different Drive or Disk Partition

Move MySQL Database File Storage Location to Different Drive or Disk Partition

As more CDR/CMR data is created by CUCM and saved by Variphy, the database storage files for MySQL can become large in size and consume disk space, particularly if located on the C drive/partition.  

It’s recommended to store the database files on a ‘data’ partition (such as the D or E drive on Windows) with adequate storage capacity and room for growth.  

To move the MySQL database files from their existing location to a different location, follow the steps below:

Step 1) Disable CDR processing for all Clusters in Variphy which use this MySQL database server to store CDR/CMR Data.  

If all Clusters in Variphy utilize this MySQL database server, then the “Variphy Insight” Windows service can stopped instead of disabling each Cluster individually.  

Step 2) Stop the MySQL Windows Service

Open Windows Services (e.g. start –> run –> “services.msc” or Control Panel > Administrative Tools > Services)

Find the appropriate MySQL Service entry (e.g. “MySQL” or “MySQL56”, or “VariphyMySQL”)

Stop the service

Step 3) Locate the configuration file used by MySQL

On Windows, this is the my.ini file.  The location of this file is often dependent on the version of Windows and MySQL.

To find where the active configuration file is located on a Windows Server:

Open Windows Services (e.g. start –> run –> “services.msc”)

Find the appropriate MySQL Service entry (Step 2 above)

Right click the service name and select Properties

Under the text “Path to executable”, the path to the my.ini file will be shown next to the parameter “–defaults-file”

In the following example, the my.ini file is C:\ProgramData\MySQL\MySQL Server 5.6\my.ini:

“C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld” –defaults-file=”C:\ProgramData\MySQL\MySQL Server 5.6\my.ini” MySQL56

Step 4) Open the MySQL configuration file in a text-editor such as Notepad or Wordpad

Find the SERVER SECTION in the file and at or near line 76, identify the datadir value.  This is the existing location where the MySQL database files are stored.

For example: datadir=C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data

Step 5) Copy the MySQL Data from the existing to the new desired storage location

Open the data folder existing datadir location and copy all the contents of the folder to the new desired location, such as D:\MySQLData.  There may be multiple/many GBs of data so so this may take serveral minutes/hours to complete.  If necessary, create the desired folders first. 

Step 6) Modify the datadir value in the MySQL Configuration File to reference the new datadir location

In the my.ini file, change the datadir value appropriately for your new data location. 

For example:

datadir=D:\MySQLData

Step 7) Restart the MySQL Windows Service

Step 8) Re-enable Clusters in Variphy CDR Manager

In Step 1 above, if particular Clusters were disabled, then re-enable each Cluster.  If the Variphy CDR Manager Windows service was stopped instead, then restart the service and login to Variphy CDR Manager to confirm all appropriate Clusters are enabled and active. 

Step 9) Lastly, Delete the old MySQL Data Files

As a last step, after confirming the everything is working properly, including the storage of new CDR/CMR data, delete the old/previous data files in the previous MySQL datadir location. 

Updated on March 30, 2020

Related Articles