Change the storage location of the MySQL database under Windows

Source: Internet
Author: User

I. Transfer of locations under the same host

After the MySQL installation is complete, modify the location of the database storage, such as from the C:\Program files\mysql\mysql Server 5.0\data folder in the installation directory to the D:\mySQLData folder.

1. Create a new Mysqldata folder under D:\

2. Stop the MySQL service and copy the folders and files under C:\Program files\mysql\mysql Server 5.0\data to the D:\mySQLData folder

3. Locate the My.ini file in the installation directory and find:

#Path to the database root
Datadir= "C:/Program files/mysql/mysql Server 5.0/data/"

Change the value of DataDir to d:/mysqldata/

Once saved, restart the MySQL service.

If you report a 1067 error, you can change the value of the DataDir to d:/mysqldata/and restart it first, My.ini

Once the reboot is successful, copy the old data files.

Windows MySQL changes database files directory and 1045,1067 errors

MySQL installation can not choose the location of the database file installation,
There is also no tool available to change the database directory directly, to change the data directory, as follows:
MySQL installation and configuration is complete, the default data cry installation directory for
C:\ProgramData\MySQL\MySQL Server 5.1\data (vist or Win7)
C:/Documents and Settings/all users/application data/mysql/mysql Server 5.1/data/(under XP),
The following is an example of Win7:
1. Normal installation and configuration of MySQL;
2. Create a new database installation directory that you want to modify, such as E:\MySQL\Data;
3. Copy all files under C:\ProgramData\MySQL\MySQL Server 5.1\data to E:\MySQL\Data;
4. Locate the installation directory for the MySQL software by default to the My.ini file in C:\Program files\mysql\mysql Server 5.1
Found it
Datadir= "C:/programdata/mysql/mysql Server 5.1/data/"
Modified to: Datadir= "E:\MySQL\Data", special attention is "\" rather than "/", otherwise not succeed (I do not know why!!!) )
5. Restart the MySQL service, create a new database directory E:\MySQL\Data a folder is a database directory.

Note: Do not delete the C:/programdata/mysql/mysql Server 5.1/data/directory (although it can be deleted) after completion because
Deleting an existing instance when reconfiguring later, and then configuring a new instance may cause problems with the service not starting because the program also defaults
C:/programdata/mysql/mysql Server 5.1/data/as the database directory ...

Important NOTES:
Installation configuration MySQL often encounters two errors
1 is 1045, this is often the re-installation or reconfiguration of the database required to enter the original password, and password errors caused by,
The workaround is to reinstall the original program before reinstalling and remove the installation directory and the MySQL directory under C:\ProgramData\ to reinstall it.
2 is 1067, this is the above mentioned changes after the database directory if the settings are incorrectly started service is encountered error, follow the above steps to avoid

Original link: transfer method under different hostObjective: To transfer the library in a machine to B machine.

1, stop the MySQL service, in the A-machine MySQL installation directory, find the My.ini file open, found in this file DataDir, the path of the data files: ibdata1 and all folders copied to the B machine D:\mysql_ Data folder (other files are log files, do not copy, these log files depend on the current system, if these log files are copied to the B machine, error);

2, install the normal MySQL in the B machine.

3. The MySQL server in the accessory B machine. Shut down the MySQL server first. Then open the MySQL installation directory, locate the My.ini file, and in this file change the value of DataDir to the location of the data file D:/mysql_data (Note: '/'). In the My.ini file, change the value of Default-storage-engine to MyISAM because the InnoDB engine does not support direct copy of the data file backup database.

4, start the MySQL server, at this time, the database changed to a machine in the library, so the user name, password are original.

After testing and adding and removing to check the change is no problem

Test environment:
A machine: XP + mysql-5.1
Machine B: Windows 2003 + mysql-5.1

Change the storage location of the MySQL database under Windows

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: 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.