Modify the default path of the MySQL data file and the default path of the mysql Data File
Link: http://www.aichengxu.com/database/8499581.htm
1. transfer at the same host location
After installing mysql, You need to modify the location of the database storage, for example, from the C: \ Program Files \ MySQL Server 5.0 \ Data folder under the installation directory to the D: \ mySQLData folder.
1. Create a mySQLData folder under D: \
2. Stop the MySQL service and copy the folders and Files under C: \ Program Files \ MySQL Server 5.0 \ Data to the D: \ mySQLData folder.
3. Find the my. ini file in the installation directory and find:
# Path to the database root
Datadir = "C:/Program Files/MySQL Server 5.0/Data /"
Change the value of datadir to D:/mySQLData/
Save and restart the mySQL service.
If the error 1067 is reported, change my. ini to D:/mySQLData/and restart the datadir instance directly,
After the restart is successful, copy all the old data files.
In windows, MySQL changes the database file directory and the error code is or.
During MySQL installation, you cannot select the location where the database files are installed,
There is no available tool to directly change the database directory. To change the data directory, use the following method:
After installing and configuring MySQL, the default database installation directory is
C: \ ProgramData \ MySQL Server 5.1 \ data (under vist or win7)
C:/Documents and Settings/All Users/Application Data/MySQL Server 5.1/Data/(under xp ),
The following uses win7 as an example:
1. install and configure MySQL normally;
2. Create a new database installation directory, such as E: \ MySQL \ Data;
3. Copy all files under C: \ ProgramData \ MySQL Server 5.1 \ data to E: \ MySQL \ Data;
4. Find the my. ini file in the default installation directory of MySQL software: C: \ Program Files \ MySQL Server 5.1.
Find
Datadir = "C:/ProgramData/MySQL Server 5.1/data /"
Change to: datadir = "E: \ MySQL \ Data". Note that it is "\" instead of "/". Otherwise, it cannot be successful (I don't know why !!!)
5. Restart the MySQL service and create a new database directory E: \ MySQL \ Data. An additional folder is the database directory.
Note: Do not delete the C:/ProgramData/MySQL Server 5.1/data/directory after completion (although it can be deleted) because
In the future, the existing instance will be deleted when you reconfigure it. When you configure a new instance, the Service may fail to start, because the program will also default
Use C:/ProgramData/MySQL Server 5.1/data/as the database directory...
Important:
MySQL installation and configuration often encounter two errors
1 is 1045, which is often caused by a wrong password that requires you to enter the original password when you reinstall or reconfigure the database,
The solution is to uninstall the original program, delete the installation directory and the MySQL directory under C: \ ProgramData \, and reinstall it.
2 is 1067. This is an error that occurs when the database directory is changed and the service is started incorrectly. Follow the steps above to avoid this problem.
Link: http://blog.csdn.net/heizistudio/article/details/8234185
-----------------------------
Ii. transfer methods under different hosts
Objective: To transfer the database in machine A to machine B.
1. Stop the mysql service. In the mysql installation directory of machine A, find my. open the INI file, find datadir in this file, and copy the data file ibdata1 and all folders in this path to the d: \ mysql_data folder in machine B (other files are log files, no need to copy. These log files depend on the current system. If all these log files are copied to machine B, an error will occur );
2. Install mysql normally on machine B.
3. mysql server in accessory B. First, shut down the mysql server. Open the mysql installation directory, find the my. ini file, and change the datadir value to the Data File Location d:/mysql_data (note '/'). In the my. ini file, change the default-storage-engine value to myisam, because the InnoDB engine does not support direct copy of data files to back up the database.
4. Start the mysql server. At this time, the database is changed to the database in machine A, so the user name and password are all original.
No problem with addition, deletion, query, modification, and so on.
Test environment:
A: xp + mysql-5.1
B: windows 2003 + mysql-5.1