MySQL is a popular open source relational database management system that can run on different operating systems, including Windows, Linux and Mac systems. When using MySQL, sometimes you need to modify its default data storage path to meet different needs or restrictions. This article will introduce how to modify the MySQL data storage path under Windows and Linux systems.
1. Modify the data storage path of MySQL under Windows system
Under Windows system, the default data storage path of MySQL is: C:ProgramDataMySQLMySQL Server 5.xData. If you need to modify it to another path, you can follow the steps below:
After completing the above steps, MySQL will store the data in the new path without re-importing the data or resetting the program.
2. Modify the data storage path of MySQL under Linux system
Under Linux system, the default data storage path of MySQL is: /var/lib/mysql. If you need to modify it to another path, you can follow the steps below:
$ sudo /etc/ init.d/mysql stop
$ sudo cp -R /var/lib/mysql /home/mysql_data
$ sudo chown -R mysql:mysql /home/mysql_data/mysql
$ sudo chmod -R 755 /home/mysql_data/mysql
$ sudo /etc/init.d/mysql start
After completing the above steps, MySQL will store the data in the new path without re-importing the data or resetting the program.
Summary:
The above are the steps to modify the MySQL data storage path under Windows and Linux systems. It should be noted that after modifying the data storage path, you must ensure that the path can be read and written. The permissions are correct, otherwise it may cause problems such as MySQL being unable to start normally or open the database. It is recommended that when making modifications, you first back up the data and conduct necessary testing and verification.
The above is the detailed content of mysql modify path. For more information, please follow other related articles on the PHP Chinese website!