LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-18-2007, 09:28 AM   #1
SlacUser
Member
 
Registered: Apr 2007
Location: México
Distribution: Slackware, Fedora
Posts: 61

Rep: Reputation: 15
MySql Data directory


Hi everyone!
Because my hard disk is out of space, I added a new hard disk, and what I want to do is to link the MySql data directory to the new device.

I tried to execute the following command as root:
Code:
ln /var/lib/mysql /mnt/dbescolar/mysql
ln '/var/lib/mysql': hard link not allowed for directory
I have read that I could change the data directory in the my.cnf file, but I can't find it, it is not in the default directory /etc/my.cnf, and I search for it in the entire pc and but nothing.

Any clue how could I do this??
 
Old 06-18-2007, 09:54 AM   #2
buggabill
Member
 
Registered: Jun 2006
Location: Maine, USA
Distribution: Kubuntu 8.10/Debian Lenny
Posts: 30

Rep: Reputation: 15
If the /var/lib/mysql directory exists already, It will have to be renamed so that the new symlink can be created. Do that as root with this
Code:
# mv /var/lib/mysql /var/lib/mysql.old
You need to create a symbolic link - like this (as root):
Code:
# ln -s /var/lib/mysql /mnt/dbescolar/mysql
As for the my.cnf file, depending on the distro you are using, they will sometimes put it in different locations like /etc/mysql/. Check there.

You could also do a find to find it:
Code:
# find / -name my.cnf
Good luck!
 
Old 06-18-2007, 09:57 AM   #3
buggabill
Member
 
Registered: Jun 2006
Location: Maine, USA
Distribution: Kubuntu 8.10/Debian Lenny
Posts: 30

Rep: Reputation: 15
One more thing...

MAKE SURE YOU COPY THE MYSQL DATA FILES TO THE NEW DIRECTORY!
 
Old 06-18-2007, 10:09 AM   #4
SlacUser
Member
 
Registered: Apr 2007
Location: México
Distribution: Slackware, Fedora
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by buggabill
If the /var/lib/mysql directory exists already, It will have to be renamed so that the new symlink can be created. Do that as root with this
Code:
# mv /var/lib/mysql /var/lib/mysql.old
You need to create a symbolic link - like this (as root):
Code:
# ln -s /var/lib/mysql /mnt/dbescolar/mysql
As for the my.cnf file, depending on the distro you are using, they will sometimes put it in different locations like /etc/mysql/. Check there.

You could also do a find to find it:
Code:
# find / -name my.cnf
But I have databases on the directory /var/lib/mysql, I need them to run some web pages. I reason to make the link is to pass the information to the other disk in order to have more space.

About the find / -name my.cnf, I already did that, but without any result. I only found examples of the configuration file, named as my-small.cnf, my-huge.cnf, my-large.cnf.
 
Old 06-18-2007, 12:24 PM   #5
buggabill
Member
 
Registered: Jun 2006
Location: Maine, USA
Distribution: Kubuntu 8.10/Debian Lenny
Posts: 30

Rep: Reputation: 15
If you copy the database files to the new directory, you should be all set. Someone PLEASE correct me if I am wrong. I do not know of a way to split the data amongst more than one directory.

My suggestion would be to copy the contents of the /var/lib/mysql to the new directory on the new hard drive, and then make the move.

Maybe there is another way. That is how I did it. I had more space in a home directory on my machine, so I made a directory called mysql under /home. I then copied all of the data files over insuring the permissions were correct. Then I renamed the /var/lib/mysql directory and created the symlink to the new location. I tested out the configuration, and all seemed to work well for me.

Here is a link that shows the installation of MySQL on Slackware http://www.generetic.org/information...slackware.html. They show copying one of the templates over to get a copy of my.cnf in /etc.
 
Old 06-19-2007, 10:48 AM   #6
SlacUser
Member
 
Registered: Apr 2007
Location: México
Distribution: Slackware, Fedora
Posts: 61

Original Poster
Rep: Reputation: 15
Job done!

I did it already!

I don't know why the my.cnf file did not exist in my system.
What I did was to modify the file /etc/rc.d/rc.mysqld, the part that defines the --datadir. I changed to /mnt/database, and then copy all the databases to the new path.

Then I give all the permissions to the user mysql in the new directory, restart the daemon, and job done! =)

Thanks all!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The postgresql data directory content in the pgsql directory is lost (empty data dir) kisembo Linux - Software 1 02-13-2006 01:11 PM
Specifying Data Directory Locations in C Source tonyfreeman Programming 1 02-07-2006 04:00 AM
mysql data import bijuhpd Linux - Newbie 1 03-05-2005 08:01 AM
outputting data from a directory to a text file? minm Linux - Newbie 2 12-19-2004 06:46 PM
MySQL Data Directory Hamma Linux - Software 1 05-28-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration