How to modify the data folder storage location of mysql in Windows

Source: Internet
Author: User

After installing mysql according to the normal steps, it is found that the default directory of datadir is
Copy codeThe Code is as follows: C: \ Documents ents and Settings \ All Users \ Application Data \ MySQL Server 5.1 \ data
Originally, the C disk capacity was not much. Of course, it cannot be placed in it ~~ Therefore, follow the online steps in my. the INI file was modified and the service was restarted in the "service". The terrible thing happened, and the error "the local computer cannot start Mysql service" occurred, I had to uninstall and reinstall it. The problem was still the same. Baidu and Google had finally solved the problem, which is summarized as follows.
1. log on to the mysql monitor command:
Copy codeThe Code is as follows:
Cmd> mysql-u root-p // then press enter to enter the password

2. Check the storage location of the database on the disk:
Copy codeThe Code is as follows: mysql> show variables like '% datadir % ';

Go to the directory under drive C to view (hidden folder). The data exists here, and each database corresponds to a folder, my goal is to change this address to the data folder under the mysql installation directory of the E disk. Be sure to proceed with caution. Otherwise, errors may occur easily.
3. Modify the data storage location
1. copy all the folders in C: \ ''''' ''' \ data to the target location E: \ ''' \ data (do not delete the data files on drive C to avoid errors in future configuration );

2. open my. INI file, find this line: datadir = "C:/ProgramData/MySQL Server 5.5/data/" changed to: datadir = "E: \ MySQL \ data ", special attention is "\" rather than "/", otherwise it cannot be successful (somehow !!!)
3.exit all calls to mysql.exe. The task manager checks whether the MySQL service has stopped. If not, run the "net stop mysql" command in cmd to stop the service. Then restart the service in net start mysql.

4. query the database location and check whether the database is successful.


Iv. Solutions to mysql crash
The slave database crashes directly, and the root user cannot log in. Resetting instance config directly causes an infinite number of failures at the start service... Finally, I tried to select remove existed instance in the first step of instance config, and then reset it again. At the end of the start, I was patient and finally recovered to normal .. OMG ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.