MySQL change data file storage path feel directly to the/etc/my.cnf in the DataDir to restart the service on the line, but search from the Internet more than n data, most of the changes in the My.cnf DataDir and sock and startup scripts/etc/rc.d/ Init/mysqld in the DataDir, according to the solution provided on the Internet seems not all right, there is no warrior to give a positive statement
In fact, only two things to do: one is MV the socket and data directory. That is, to move it from the original directory to the specified location, and second, to modify the configuration file, if it is started directly with the command below Mysql/bin, Directly change the MY.CNF can be, that is, the directory of Ocket and data to the location you moved to, if you want it on the boot can automatically start services or use service to start, the estimated need to modify/etc/rc.d/init/ The DataDir in the mysqld.
There is one more:
First look at the database in the database of the current data file storage path:
Copy Code code as follows:
Mysql> Show variables like '%dir% ';
+----------------------------+----------------------------+
| variable_name | Value |
+----------------------------+----------------------------+
| Basedir | / |
| Character_sets_dir | /usr/share/mysql/charsets/|
| DataDir | /data/mysql/|
| Innodb_data_home_dir | |
| Innodb_log_arch_dir | |
| Innodb_log_group_home_dir |./|
| innodb_max_dirty_pages_pct | 90 |
| Slave_load_tmpdir | /tmp/|
| Tmpdir | /tmp/|
+----------------------------+----------------------------+
If you think this path is possible, you don't have to change it. If you feel dissatisfied, you can also change.
1:service MySQL Stop
Close Database
2:vi/etc/rc.d/init.d/mysql
3: Change the datadir=/var/lib/mysql here to what you want. It's OK.
4:service MySQL Start
How to change the MySQL data file path