patternsqlMajor
Change existing datadir path
Viewed 0 times
existingdatadirpathchange
Problem
I want to change the
The existing
The size of my
Is this possible?
My machine is running Windows Server 2003.
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 30 GB and the MySQL data folder is occupying 25 GB. So I want to change the datadir to F:/naveen/data.Is this possible?
My machine is running Windows Server 2003.
Solution
From your paths, I can safely assume the following:
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
Please run the following in a DOS Window:
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:
If you are asked to create it, please do so.
Next, create the following entry under the [mysqld] group header in my.ini:
Save my.ini
Next, stop mysql from the DOS command line like this:
Next, make a copy of the entire data folder in the new location
Last step, start up mysql
Try logging into mysql. Once you can login to mysql successfully, run this command:
If
Once you are satisfied all your apps hitting MySQL works, you can delete everything in
Give it a Try !!!
- 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 *.iniYou 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.iniIf 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/dataSave my.ini
Next, stop mysql from the DOS command line like this:
C:\> net stop mysqlNext, 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 /sLast step, start up mysql
C:\> net start mysqlTry 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 !!!
Code Snippets
cd C:/ProgramData/MySQL/MySQL Server 5.1
dir *.inicd C:/ProgramData/MySQL/MySQL Server 5.1
notepad my.ini[mysqld]
datadir=F:/naveen/dataC:\> net stop mysqlC:\> xcopy "C:\ProgramData\MySQL\MySQL Server 5.1\data" F:\naveen\data /sContext
StackExchange Database Administrators Q#24403, answer score: 35
Revisions (0)
No revisions yet.