How to change the storage path for MYSQL database files?

To change the storage path of the MySQL database file, you can follow the steps below:

  1. Stop the MySQL service.
  2. Locate the MySQL configuration file my.cnf (usually found in the bin folder within the MySQL installation directory for Windows systems and in the /etc/mysql or /etc directory for Linux systems).
  3. Open the my.cnf file and locate the [mysqld] section.
  4. Add or modify the following parameters in the [mysqld] section:
  5. datadir: specifies the location where MySQL data files are stored.
  6. innodb_data_home_dir: Specifies the directory where the data files for the InnoDB engine are stored.
  7. innodb_log_group_home_dir: specifies the location where InnoDB engine’s log files are stored.
  8. innodb_undo_directory: specifies the path where InnoDB engine’s undo log files are stored.
  9. For example,
  10. [mysqld]
    Data will be stored in the new data path, while log and undo files will be stored in the new log and undo paths.
  11. Note: The path must be an absolute path.
  12. Save and close the my.cnf file.
  13. Start the MySQL service.

After completing the above steps, the file storage path for the MySQL database will be changed to the specified path.

bannerAds