Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to move everything that is related to my current MySQL database(s) into a subdirectory of /home/mysql. I don't need to move log files or my.cnf, only data.

I don't know where the actual database files are stored and how to tell MySQL to load them from a different directory after I move them.

Can you give me some guidance?

share|improve this question
up vote 1 down vote accepted

The data directory is specified by the datadir variable. You can check to see what the current data directory is with a:

show variables like 'datadir';

In your my.cnf under the [mysqld] section you can set:



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.