Method One:
Refer to the method under Windows, move the/var/lib/mysql to the desired directory, modify the/etc/my.cnf file, and specify the data directory. This aspect of the tutorial online a lot, you can go to search.
Shut down MySQL Service
There are three settings in My.ini [Mysqld], and the path is changed to the path after the move
| The code is as follows |
Copy Code |
Basedir= "d:/mysql-5.0.15b/" Datadir= "D:/mysql-5.0.15b/data" Innodb_data_home_dir= "D:/mysql-5.0.15b/data" |
It would be nice to restart the MySQL service.
Here are the corresponding folders and files in the folders that were just moved.
Basedir, will affect the bin directory, affecting services;
DataDir, affecting the database storage path;
The basedir must be set when migrating, or it will basically cause the service to fail to start, ibdata1 typically on the upper level of the Data folder.
Another InnoDB data file ibdata1 if not placed in the default location, then be sure to set up, otherwise the first time the service can be started, and will be in the path should be stored ibdata1 a new initial ibdata1 file, looks normal, However, the data for all databases using the InnoDB storage engine will be lost and may fail to start, or all sorts of unexpected errors, when restarted again.
Method Two:
Using the soft connection method under Linux, the following actions are as follows: (to migrate to the/home/mysql/directory for example)
Stop MySQL First:
| The code is as follows |
Copy Code |
/etc/init.d/mysqld stop Move data: mv/var/lib/mysql/*/home/mysql/ To create a soft connection: Ln-s/home/mysql//var/lib/mysql/ Start MySQL: /etc/init.d/mysqld start |
Move data:
Mv/var/lib/mysql/home/mysql
To create a soft connection:
Ln-s/home/mysql/var/lib/mysql
The two commands mean: To move the MySQL in the/var/lib/directory to the/home/directory and keep the original directory properties
Create a soft connection MySQL directory that links to the/home/mysql/directory under the/var/lib/directory.
Summarize
Have a lot of friends on the internet said to use
Move data:
mv/var/lib/mysql/*/home/mysql/
To create a soft connection:
Ln-s/home/mysql//var/lib/mysql/
People need to pay attention to Ah, this method is not not to be unsafe.