linux modifies the path to the mysql database file

  • 2020-05-12 06:22:19
  • OfStack

mysql change the storage of data file path feeling directly/etc/my cnf datadir restart under 1 instead of the service line, but searched n much information from the Internet, most of them are change my. cnf datadir and sock and startup scripts/etc/rc d init/mysqld datadir, according to the plan provided by online seems to be not, is there a warrior give a positive statement

There are only two things to do: 1 is the socket and data directories under mv1. That is, move it from the original directory to the specified location; 2, is to modify the configuration file, if directly with mysql/bin the following command to start the, direct change my. cnf, namely the ocket and data change directory to you move to the position, if is it in the boot automatically start services or use service start, estimates that need to be modified/etc/rc d init/mysqld datadir.

One more:

First, have a look at the location 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 okay, you don't have to change it. If you are not satisfied, you can modify it.

1: service mysql stop

Shut down the database

2: vi/etc/rc d/init d/mysql

3: change datadir=/var/lib/mysql to what you want. Is OK

4: service mysql start

How do I change the MySQL data file path

Related articles: