Home  >  Article  >  Database  >  How to modify the MySQL data directory under Windows

How to modify the MySQL data directory under Windows

coldplay.xixi
coldplay.xixiOriginal
2020-10-20 14:38:514695browse

How to modify the MySQL data directory under Windows: First stop the MySQL service and create a new data file directory; then copy the data file and authorize the new data file directory; then modify the [my.ini] file ;Finally start MySQL.

How to modify the MySQL data directory under Windows

How to modify the MySQL data directory under Windows:

Stop the MySQL service:

MySQL service in windows services, stop.

Create a new data file directory:

This is the MySQL data directory you want to store now, for example: E:\MySQL5.6Data

Copy data files:

Copy the "data files and subdirectories" in the original data directory to the E:\MySQL5.6Data directory just created; pay attention to your original data files Do not copy the wrong directory and data files. If you have not modified the original directory much, the original directory should look like "..\ProgramData\MySQL\...\data\". Copy the contents of the data directory to in a new directory.

New data file directory authorization

This step is very important. Many students cannot start MySQL because of this, and only have 1067 errors.

Right-click the new directory E:\MySQL5.6Data, select the "Security" tab, and grant full control permissions to all the following users and groups (Note: You can do this on the test machine, if it is a production environment , you need to try one by one until the 1067 error is not reported).

Modify the my.ini file

Many articles on the Internet say that my.ini is in the MySQL installation directory. Many people may find that my.ini does not exist in that location. File, there is only one my-default.ini file, this file is basically useless.

Non-installation version of MySQL: the my.ini configuration file may be in this directory;

Installation version of MySQL: Most of the my.ini files are in your In the data file directory, if it is not there, you can right-click the MySQL service in the Windows service list, select Properties, and you can see the executable file path in the "General" tab, followed by a --defaultFile parameter. After this parameter The value is the path to your my.ini file.

After finding the my.ini file, open it and modify the value of datadir to a new directory, such as E:\MySQL5.6Data; in most cases, just modify this place, but in order to ensure some "mutation" , you can check whether the change needs to be completed by searching for the original data path keywords (such as the original drive letter).

Save after modification. If you are installing the MySQL version and the my.ini file is in the original data file directory, you still need to do two things:

1. Copy the my.ini file to the MySQL installation directory or the new data file directory;

2. Open "Run" in windows r, enter regedit and press Enter to open the registry, HKEY_LOCAL_MACHINE-->SYSTEM--> ;CurrentControlSet-->Find the MySQL service key under services, and then modify its ImagePath attribute value to the new absolute path of the my.ini file.

Start MySQL

In the MySQL service list, start MySQL.

More related free learning recommendations: mysql tutorial(Video)

The above is the detailed content of How to modify the MySQL data directory under Windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn