View Full Version : [Solved] Moving MySQL data dir
ph0enix
May 2nd, 2009, 18:16
I'm trying to move the MySQL data dir from /var/db/mysql to /usr/mysql so I stopped MySQL, copied the contents of /var/db/mysql to /usr/mysql and updated my.cnf with:
mysql-data-dir=/usr/mysql/
...but MySQL isn't starting now. Do I need to set the permissions on /usr/mysql in a specific way?
I'm running MySQL v.5.0.77.
Thanks! :)
J.
DutchDaemon
May 2nd, 2009, 18:36
What are the permissions of the /usr/mysql directory? By the way, if you look at the command line of a running mysql installation (ps axww), you will see that a lot of stuff points to /var/db/mysql, not just the data dir. The better option would be to symlink /var/db/mysql to /usr/mysql and leave internals and flags alone.
40328 p0- I 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --
pid-file=/var/db/mysql/[redacted].pid
40379 p0- I 4:36.08 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --
user=mysql --log-error=/var/db/mysql/[redacted].err --pid-file=/var/db/mysql/[redacted].pid
ph0enix
May 2nd, 2009, 18:57
What are the permissions of the /usr/mysql directory? By the way, if you look at the command line of a running mysql installation (ps axww), you will see that a lot of stuff points to /var/db/mysql, not just the data dir. The better option would be to symlink /var/db/mysql to /usr/mysql and leave internals and flags alone.
40328 p0- I 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --
pid-file=/var/db/mysql/[redacted].pid
40379 p0- I 4:36.08 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --
user=mysql --log-error=/var/db/mysql/[redacted].err --pid-file=/var/db/mysql/[redacted].pid
DutchDaemon to the rescue as usual :D
symlinking /var/db/mysql to /usr/mysql did the trick!
Thank you! :)
J.
dave
August 25th, 2009, 06:08
To move the just db dir, you can specify in rc.conf:
mysql_dbdir="/usr/local/mysql/data"
Be sure to give mysql read-write access.
phospher
January 12th, 2011, 19:37
Hmm, I can't seem to get this symlink correct though I've done it before...
I've ran into this very same issue and I'm trying to link /var/db/mysql to /usr/mysql
When I enter the command: ln -s /usr/mysql /var/db/mysql
I get the error: ln: /var/db/mysql/mysql: file exists
I should also add that if I do:ln -s /var/db/mysql /usr/mysql
Then /usr/mysql points to /var/db/mysql.
mysql -> /var/db/mysql
Thoughts? Thanks
phospher
January 12th, 2011, 21:10
Ah, I got it. Guess I had to mv the mysql directory over first.
ph0enix
January 22nd, 2011, 02:11
I should also add that if I do:ln -s /var/db/mysql /usr/mysql
Then /usr/mysql points to /var/db/mysql.
mysql -> /var/db/mysql
That's the way to do it. You want /usr/mysql to point to /var/db/mysql assuming that's where you planning to store the data.
ph0enix
January 22nd, 2011, 02:12
Ah, I got it. Guess I had to mv the mysql directory over first.
Not sure what you mean by this? What exactly did you do?
phospher
February 9th, 2011, 04:27
Not sure what you mean by this? What exactly did you do?
I actually wanted the mysql database to be located at /usr/mysql. I copied the database from /var/db/mysql to /usr/mysql then ran: ln -s /usr/mysql /var/db/mysql
And it worked. I *think* it wasn't working because /usr/mysql did not exist?? Not sure..
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.