Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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! =)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.