Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to change the datadir path in the my.ini file.

The existing datadir path is C:/ProgramData/MySQL/MySQL Server 5.1/Data/

The size of my C: drive is 30GB and the MySQL data folder is occupying 25GB. So I want to change the datadir to F:/naveen/data.

Is this Possible?

My machine is running Windows Server 2003.

share|improve this question
add comment

1 Answer

From your paths, I can safely assume the following:

  • You are running MySQL in Windows
  • You used the MySQL MSI to install

What you need to do is establish the file my.ini

When installing MySQL for Windows using the MSI, the location of my.ini is expected to be C:/ProgramData/MySQL/MySQL Server 5.1.

Please run the following in a DOS Window:

cd C:/ProgramData/MySQL/MySQL Server 5.1
dir *.ini

You will see some sample my.ini files. However, if there is no file named my.ini in that folder, you must create one. Whether one exists or not, please run this:

cd C:/ProgramData/MySQL/MySQL Server 5.1
notepad my.ini

If you are asked to create it, please do so.

Next, create the following entry under the [mysqld] group header in my.ini:

[mysqld]
datadir=F:/naveen/data

Save my.ini

Next, stop mysql from the DOS command line like this:

C:\> net stop mysql

Next, make a copy of the entire data folder in the new location

C:\> xcopy "C:\ProgramData\MySQL\MySQL Server 5.1\data" F:\naveen\data /s

Last step, start up mysql

C:\> net start mysql

Try logging into mysql. Once you can login to mysql successfully, run this command:

show variables like 'datadir';

If F:\naveen\data shows up as the datadir, CONGRATULATIONS, YOU HAVE DONE IT RIGHT !!!

Once you are satisfied all your apps hitting MySQL works, you can delete everything in C:\ProgramData\MySQL\MySQL Server 5.1\data\*

Give it a Try !!!

share|improve this answer
    
Its working Thank you Rolando, –  user12712 Sep 18 '12 at 9:17
    
@naveenkumar If the answer solved your issue, you can indicate this by clicking the check mark below the vote score on the top left of the answer text. You can also upvote by clicking the up arrow. –  JNK Sep 18 '12 at 12:08
    
May I know the above steps will work for windows server 2008 ? –  user12712 Sep 19 '12 at 9:38
add comment

Your Answer

 
discard

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.