Moving MySQL data dir

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:

Code:
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.
 
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.

Code:
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 said:
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.

Code:
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.
 
To move the just db dir, you can specify in rc.conf:

Code:
mysql_dbdir="/usr/local/mysql/data"

Be sure to give mysql read-write access.
 
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: [cmd=]ln -s /usr/mysql /var/db/mysql[/cmd]

I get the error:
Code:
ln: /var/db/mysql/mysql: file exists

I should also add that if I do:[cmd=]ln -s /var/db/mysql /usr/mysql[/cmd]

Then /usr/mysql points to /var/db/mysql.
Code:
 mysql -> /var/db/mysql

Thoughts? Thanks
 
phospher said:
I should also add that if I do:[cmd=]ln -s /var/db/mysql /usr/mysql[/cmd]

Then /usr/mysql points to /var/db/mysql.
Code:
 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 said:
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: [cmd=]ln -s /usr/mysql /var/db/mysql[/cmd]

And it worked. I *think* it wasn't working because /usr/mysql did not exist?? Not sure..
 
Back
Top