[Klug-general] Moving MYsql data stores
MacGyveR
macgyver at thedumbterminal.co.uk
Tue Apr 18 19:58:36 BST 2006
On Tuesday 18 Apr 2006 13:01, dan attwod wrote:
> Hello does anyone konw how shift a MYsql data store from one lace to
> another?
> I've installed MYsql via synaptic. However I want the data to be in
> /opt/mysql/ and not the default /var/lib/mysql.
>
> I Tried compiling from source with the data directory flag but it just hung
> I then tried picking up the data file and moving it to the new directory.
> However it won't then let me reset the permissions on the moved folders
> (chown refused to work) and it also wouldn't copy mysql.sock.
>
> I'm doing all this in PClinuxos by the way
>
> Dan
Dan,
There are a few issues here:
* use "cp -a" when copying the files as this will keep the permissions on them
* make sure the mysql user can access /opt/mysql
* stop the server first, then you can just delete the socket file, it will be
recreated on the next mysql start
* not sure why chown, chmod is not working for you, but as a workaround just
do "mv /var/lib/mysql" and then "ln -s /opt/mysql /var/lib/mysql " to create
symlink to the new location.
* i mention the symlink above as you will need to update mysql's config
in /etc/my.cnf but also the DATADIR and BASEDIR setting might be hardcoded
in /etc/init.d/mysql.server or whatever synaptic users.
* you could jsut dump your databases and create the symlink then do a
"mysql_install_db" and that will create the files withe the correct
permissions.
Why do you want to install mysql's datadir in /opt anyway as that's not really
the correct location. See below for more info:
http://www.pathname.com/fhs/
--
--------------------------------
http://www.thedumbterminal.co.uk
More information about the Kent
mailing list