473,395 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to change mysql database directory

43
I am using Linux RedHat , MySql Ver 14.12 Distrib 5.0.18

not enough disk space left on /dev/sda7, which I am working on,
I insert BLOBs into database and the table is as big as 5.54468 GB

I want to change the database to another directory which is on /dev/sda8 .

I think I should use mysqldump to backup the table , after change the directory for mysql , and then use the backup file to recover it.

But now I do not know how to change the directory of database. Who knows Please Help . Thanks a million.
Apr 11 '07 #1
3 12286
masdi2t
37
I am using Linux RedHat , MySql Ver 14.12 Distrib 5.0.18

not enough disk space left on /dev/sda7, which I am working on,
I insert BLOBs into database and the table is as big as 5.54468 GB

I want to change the database to another directory which is on /dev/sda8 .

I think I should use mysqldump to backup the table , after change the directory for mysql , and then use the backup file to recover it.

But now I do not know how to change the directory of database. Who knows Please Help . Thanks a million.
this is the step:
1. shutdown your mysql server (clean shutdown).
2. copy your data directory (all your data including your ib_logfile, ibdata).
3. open your mysql configuration file (my.cnf) and make some update on it.
a. adjust your datadir to your new directory (for myisam).
b. if you use innodb storage engine, make this modification too:
i. modify innodb_data_home_dir to your new directory.
ii. modify innodb_data_file_path. adjust ibdata size by round it down to the closest multiple of 1024 × 1024 bytes. ex: you have 100MB of ibdata, this calculation will produce 100.000.000 / 1024 / 1024 = 95.xxx MB, then you sholud write ibdata1:95M:autoextend.
iii. this is also your chance to resize your log file. if you did a clean shutdown, then you can delete your current log file (you do not need this file to make instance recovery because of clean shutdown you already did). to resize your log file just specify your new size on innodb_log_file_size, for example 100M

4. start your mysql server
5. happy migrating
Apr 13 '07 #2
tanyali
43
Thank you very much for answering,

Sorry to say that I am new.... so Can you explain every step more detail with command,
eg. how to shutdown mysql server....
I tried : mysqladmin -u root -p shutdown..
but it said :
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

where is the directory of my.cnf ?

Thanks a million again

this is the step:
1. shutdown your mysql server (clean shutdown).
2. copy your data directory (all your data including your ib_logfile, ibdata).
3. open your mysql configuration file (my.cnf) and make some update on it.
a. adjust your datadir to your new directory (for myisam).
b. if you use innodb storage engine, make this modification too:
i. modify innodb_data_home_dir to your new directory.
ii. modify innodb_data_file_path. adjust ibdata size by round it down to the closest multiple of 1024 × 1024 bytes. ex: you have 100MB of ibdata, this calculation will produce 100.000.000 / 1024 / 1024 = 95.xxx MB, then you sholud write ibdata1:95M:autoextend.
iii. this is also your chance to resize your log file. if you did a clean shutdown, then you can delete your current log file (you do not need this file to make instance recovery because of clean shutdown you already did). to resize your log file just specify your new size on innodb_log_file_size, for example 100M

4. start your mysql server
5. happy migrating
Apr 13 '07 #3
tanyali
43
Thanks for your answer ,

I have a problem after I did this :
I changed the location of mysql in linux by following this :
change database location

I changed every old-directory in the file /etc/my.cnf to new-directory, when I copied all the files from the old-directory to the new-directory some files omitted copy.. which are database-file.... (eg. I have a database named 'test' and many tables in 'test', I can not copy the file named test.)

at last I created a file with the same name and copied everything inside the file across to the new-directory. .. I think properly this causes the problem ,
then I restarted mysql server,, it does not work.
it still goes to the old-directory to look for mysql.sock..

do you know how to deal with this.. ?? thanks first
Tanya





this is the step:
1. shutdown your mysql server (clean shutdown).
2. copy your data directory (all your data including your ib_logfile, ibdata).
3. open your mysql configuration file (my.cnf) and make some update on it.
a. adjust your datadir to your new directory (for myisam).
b. if you use innodb storage engine, make this modification too:
i. modify innodb_data_home_dir to your new directory.
ii. modify innodb_data_file_path. adjust ibdata size by round it down to the closest multiple of 1024 × 1024 bytes. ex: you have 100MB of ibdata, this calculation will produce 100.000.000 / 1024 / 1024 = 95.xxx MB, then you sholud write ibdata1:95M:autoextend.
iii. this is also your chance to resize your log file. if you did a clean shutdown, then you can delete your current log file (you do not need this file to make instance recovery because of clean shutdown you already did). to resize your log file just specify your new size on innodb_log_file_size, for example 100M

4. start your mysql server
5. happy migrating
Apr 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: James | last post by:
HI, I'm looking for a script that will allow users/admins to have a one click backup solution for a MYSQL Database.. 'BACK DATABASE' button, click and its done... The a restore option, that...
2
by: Saqib Ali | last post by:
I installed mySQL and have it running.... but I think I made a mistake somewhere along the line...... I believe I did follow the instructions that were provided with the distribution at:...
1
by: Alex Hunsley | last post by:
I am trying to install the DBD::mysql perl module. However, it claims I need mysql.h: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /home/alex/.cpan/Metadata Database was...
7
by: MLH | last post by:
I have an sql script file that is supposed to create a set of database tables for me. Supposedly I type the following on my linux box and its all supposed to work... mysql (ENTER) \....
4
by: MLH | last post by:
I am having failures processing the following command and I wonder if you can tell me what I must do in order to have success. When I try to run source mysql_dump.sql.txt ==> it is a problem...
10
by: MLH | last post by:
I have a database named credifree. I did it with mysql's create command. Yet, I can find no files on my linux box except for a\ directory and a gif file that have the name credifree. Why? What's...
2
by: GS | last post by:
Implemented web application using MySQL to maintain inventory of the office PC's/laptops/Routers/hubs and other stuff, here we are using MySQL as back-end Database on Linux Operating system. I need...
18
by: Bruce A. Julseth | last post by:
I have the following code $Host = "localhost"; $User = "Fred"; $Database = "house"; $Password = "mypw" echo "before mysqli<br />Host: " . $Host . "<br />" . $User . "<br />" . $Database;
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.