Re: How to move the MySQL data directory?
On 03.05.2006 01:21 (+0100), paul rivers wrote: Specify the data dir in the local my.cnf and be sure your instance uses it by starting it with the --defaults-file parameter set to that instance's local copy. Okay, since hacking seems to be required anyway, I hacked it the straight-forward and least-change way. I already had datadir=... changed in the init script to the correct location. Now I also insert some variables corrections in bin/mysqld_safe: # here are the lines where ledir is set totally wrong... MY_BASEDIR_VERSION=`pwd` ledir=${MY_BASEDIR_VERSION}/bin DATADIR=`pwd | sed -r s;/usr/local/;/var/;`/data defaults=--defaults-file=${DATADIR}/my.cnf # user=... and so on This does the job pretty well for MySQL 4.0. Need to do it with every upgrade, but I think I can automate it. MySQL 5.0 required a less invasive hack though. I saw that setting datadir= in the proposed init script is for nothing at the very beginning since it's overwritten again right below. So moving that line further down helped. Then the mysqld_safe call in the 'start' section required an additional parameter --defaults-file=$datadir/my.cnf to make it read my socket name, IP port etc. Now both servers are up and running fine again, side by side, with the *entire* data directory moved somewhere else, saving me from handling that with every upgrade. Thanks for your help, I thought it could be done an easy way but it seems nobody has thought about doing that before. At least I don't have the impression, from reading the scripts. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de – My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: How to move the MySQL data directory?
Hi Yves, You could also have changed the directory in the global /etc/my.cnf file by setting datadir=/path/to/mysql/data This is pretty simple and works a lot easier than hacking the init scripts. Regards --- ** _/ ** David Logan *** _/ *** ITO Delivery Specialist - Database *_/* Hewlett-Packard Australia Ltd _/_/_/ _/_/_/ E-Mail: [EMAIL PROTECTED] _/ _/ _/ _/ Desk: +618 8408 4273 _/ _/ _/_/_/ Mobile: 0417 268 665 *_/ ** ** _/ Postal: 148 Frome Street, _/ ** Adelaide SA 5001 Australia invent --- -Original Message- From: Yves Goergen [mailto:[EMAIL PROTECTED] Sent: Wednesday, 3 May 2006 8:01 PM To: paul rivers Cc: mysql@lists.mysql.com Subject: Re: How to move the MySQL data directory? On 03.05.2006 01:21 (+0100), paul rivers wrote: Specify the data dir in the local my.cnf and be sure your instance uses it by starting it with the --defaults-file parameter set to that instance's local copy. Okay, since hacking seems to be required anyway, I hacked it the straight-forward and least-change way. I already had datadir=... changed in the init script to the correct location. Now I also insert some variables corrections in bin/mysqld_safe: # here are the lines where ledir is set totally wrong... MY_BASEDIR_VERSION=`pwd` ledir=${MY_BASEDIR_VERSION}/bin DATADIR=`pwd | sed -r s;/usr/local/;/var/;`/data defaults=--defaults-file=${DATADIR}/my.cnf # user=... and so on This does the job pretty well for MySQL 4.0. Need to do it with every upgrade, but I think I can automate it. MySQL 5.0 required a less invasive hack though. I saw that setting datadir= in the proposed init script is for nothing at the very beginning since it's overwritten again right below. So moving that line further down helped. Then the mysqld_safe call in the 'start' section required an additional parameter --defaults-file=$datadir/my.cnf to make it read my socket name, IP port etc. Now both servers are up and running fine again, side by side, with the *entire* data directory moved somewhere else, saving me from handling that with every upgrade. Thanks for your help, I thought it could be done an easy way but it seems nobody has thought about doing that before. At least I don't have the impression, from reading the scripts. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de - My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: How to move the MySQL data directory?
Apologies, I didn't read your initial posting properly. Perhaps a glance at this http://dev.mysql.com/doc/refman/5.0/en/mysqld-multi.html would provide you the facilities that you require for using multiple servers. This work well and enables you to manage the multiple global configuration files required. Regards Hi Yves, You could also have changed the directory in the global /etc/my.cnf file by setting datadir=/path/to/mysql/data This is pretty simple and works a lot easier than hacking the init scripts. Regards --- ** _/ ** David Logan *** _/ *** ITO Delivery Specialist - Database *_/* Hewlett-Packard Australia Ltd _/_/_/ _/_/_/ E-Mail: [EMAIL PROTECTED] _/ _/ _/ _/ Desk: +618 8408 4273 _/ _/ _/_/_/ Mobile: 0417 268 665 *_/ ** ** _/ Postal: 148 Frome Street, _/ ** Adelaide SA 5001 Australia invent --- -Original Message- From: Yves Goergen [mailto:[EMAIL PROTECTED] Sent: Wednesday, 3 May 2006 8:01 PM To: paul rivers Cc: mysql@lists.mysql.com Subject: Re: How to move the MySQL data directory? On 03.05.2006 01:21 (+0100), paul rivers wrote: Specify the data dir in the local my.cnf and be sure your instance uses it by starting it with the --defaults-file parameter set to that instance's local copy. Okay, since hacking seems to be required anyway, I hacked it the straight-forward and least-change way. I already had datadir=... changed in the init script to the correct location. Now I also insert some variables corrections in bin/mysqld_safe: # here are the lines where ledir is set totally wrong... MY_BASEDIR_VERSION=`pwd` ledir=${MY_BASEDIR_VERSION}/bin DATADIR=`pwd | sed -r s;/usr/local/;/var/;`/data defaults=--defaults-file=${DATADIR}/my.cnf # user=... and so on This does the job pretty well for MySQL 4.0. Need to do it with every upgrade, but I think I can automate it. MySQL 5.0 required a less invasive hack though. I saw that setting datadir= in the proposed init script is for nothing at the very beginning since it's overwritten again right below. So moving that line further down helped. Then the mysqld_safe call in the 'start' section required an additional parameter --defaults-file=$datadir/my.cnf to make it read my socket name, IP port etc. Now both servers are up and running fine again, side by side, with the *entire* data directory moved somewhere else, saving me from handling that with every upgrade. Thanks for your help, I thought it could be done an easy way but it seems nobody has thought about doing that before. At least I don't have the impression, from reading the scripts. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de - My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How to move the MySQL data directory?
On 03.05.2006 12:34 (+0100), Logan, David (SST - Adelaide) wrote: You could also have changed the directory in the global /etc/my.cnf file by setting datadir=/path/to/mysql/data This is pretty simple and works a lot easier than hacking the init scripts. As I said, there are two MySQL servers and there is no such global config file which all scripts seem to assume. There is one for each server and they are located in the datadir to make it easy (following the default setup). -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de – My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How to move the MySQL data directory?
On 5/2/06, Yves Goergen [EMAIL PROTECTED] wrote: But upgrading MySQL like installing it after MySQL's guide brings a problem: I'd need to move the data directory to the new programme directory every time. That is what I do. I find it easier than moving the data directory to a non-standard location. I wrapped it all in a shellscript to be run by root. Assuming mysql is installed in /usr/local like this: lrwxr-xr-x 1 root wheel 37 May 2 14:34 mysql - mysql-standard-5.0.20a-osx10.4-powerpc drwxr-xr-x 19 root mysql 646 May 2 14:34 mysql-standard-5.0.20a-osx10.4-powerpc And I have a tar.gz 'mysql-standard-5.0.21-osx10.4-powerpc.tar.gz', and the script below is called 'update-mysql.sh', this: # update-mysql.sh mysql-standard-5.0.21-osx10.4-powerpc.tar.gz Updates mysql to version 5.0.21. All I have to do manually is remove the directory with the old version. I'm sure I could automate that also but I thought it was good enough like this. #!/bin/sh tarfile=$1 usrlocal='/usr/local' olddir='mysql' newdir=${tarfile%.tar.gz} password='secret' mysqladmin -u root --password=$password shutdown sleep 5 mv $tarfile $usrlocal cd $usrlocal tar xvzf $tarfile cd $newdir rm -r data chown -R root:mysql . cd ../$olddir mv data ../$newdir/ cd .. rm $olddir ln -s $newdir $olddir rm $tarfile mysqld_safe -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
How to move the MySQL data directory?
Hello, I've just wanted to update MySQL 5.0 on my test machine that will be a productive server very soon. But upgrading MySQL like installing it after MySQL's guide brings a problem: I'd need to move the data directory to the new programme directory every time. So I want to move the datadir outside the application's directory, from /usr/local/mysql5/data (with mysql5 being a symlink to mysql-5.0.xx-...) to /var/mysql5/data. So I moved the entire data directory to the new location and tried to start the MySQL server. After a while printing out dots, it says ERROR! and that's it. When I have tried it with MySQL 4.0 and after adding some more of the suppressed output to the scripts, it seems like the startup script expects at least the mysql database to be located inside $basedir/data/mysql which of course is not what I meant to do. Is this true that MySQL wants all its databases to be inside the programme directory? Is there any other way to move the datadir out there without hacking all the scripts - over and over with each update? (Then I could just as well move the datadir each time...) -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de – My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How to move the MySQL data directory?
Well, moving the datadir to the new MySQL 5.0.21 directory, messing around with all the stupid symlinks, it seems I have finally managed to delete that datadir... It was empty anyway, yet, but this is an extremely dangerous task. So I really need to move the datadir to a safe place, outside all that symlinked chaos. With that done, what is the proposed upgrade method anyway? 1. unpack the tarball to /usr/local/mysql-$version 2. chown root:mysql it all (what for, actually?) 3. stop the server 4. update the symlink /usr/local/mysql5 to the new directory 5. start the server Would that be okay? -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de – My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How to move the MySQL data directory?
The easiest way might be to tell mysql in the config file where to look for the data directory. In your my.cnf file (typically /etc/my.cnf) under the [mysqld] section: datadir = /Volumes/mysql-data/data Dan -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How to move the MySQL data directory?
On 02.05.2006 22:24 (+0100), Dan Buettner wrote: The easiest way might be to tell mysql in the config file where to look for the data directory. In your my.cnf file (typically /etc/my.cnf) under the [mysqld] section: datadir = /Volumes/mysql-data/data One of the main problems with a global config file is that I am running two servers on the same machine (MySQL 4.0 and 5.0, each with separate data directories of course). Currently I am using config files (my.cnf) in each server's data directory, but telling the server about another datadir inside that other datadir is obiously not reasonable. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de – My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: How to move the MySQL data directory?
Specify the data dir in the local my.cnf and be sure your instance uses it by starting it with the --defaults-file parameter set to that instance's local copy. Regards, Paul -Original Message- From: Yves Goergen [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 3:11 PM To: Dan Buettner Cc: mysql@lists.mysql.com Subject: Re: How to move the MySQL data directory? On 02.05.2006 22:24 (+0100), Dan Buettner wrote: The easiest way might be to tell mysql in the config file where to look for the data directory. In your my.cnf file (typically /etc/my.cnf) under the [mysqld] section: datadir = /Volumes/mysql-data/data One of the main problems with a global config file is that I am running two servers on the same machine (MySQL 4.0 and 5.0, each with separate data directories of course). Currently I am using config files (my.cnf) in each server's data directory, but telling the server about another datadir inside that other datadir is obiously not reasonable. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] http://beta.unclassified.de - My web laboratory. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]