Linux modifies the path to the mysql database file
mysql Changing the storage path of the data file feels like directly changing the datadir in/etc/my.cnf and restarting the service That's fine, but I have searched more than n information from the Internet, most of which are to change the datadir and sock in my.cnf and the startup script/etc/rc.d/init/mysqld does not seem to work according to the scheme provided on the Internet.Is there any hero to give a positive statement
In fact, it only needs to do two things: One is the directory of mv socket and data.That is to move it from the original directory to the specified location; second, it is to modify the configuration file, if it is directly started with the command under mysql/bin, just change my.cnf directly, that is, to put the ocket and data Change the directory to the location you moved to.If you want it to automatically start the service or use the service to start when booting, it is estimated that you need to modify the datadir in/etc/rc.d/init/mysqld.
Another one:
First look at the storage path of the current data file in the database:
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 ok, you don’t need to modify it.If you feel unsatisfied, you can also modify it.
1: service mysql stop
Shut down the database
2: vi/etc/rc.d/init.d/mysql
3: put datadir=/var/lib/mysql Change here to what you want.OK
4: service mysql start
How to change the MySQL data file path
In fact, it only needs to do two things: One is the directory of mv socket and data.That is to move it from the original directory to the specified location; second, it is to modify the configuration file, if it is directly started with the command under mysql/bin, just change my.cnf directly, that is, to put the ocket and data Change the directory to the location you moved to.If you want it to automatically start the service or use the service to start when booting, it is estimated that you need to modify the datadir in/etc/rc.d/init/mysqld.
Another one:
First look at the storage path of the current data file in the database:
The code is 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 ok, you don’t need to modify it.If you feel unsatisfied, you can also modify it.
1: service mysql stop
Shut down the database
2: vi/etc/rc.d/init.d/mysql
3: put datadir=/var/lib/mysql Change here to what you want.OK
4: service mysql start
How to change the MySQL data file path
0 Comments