Bug #2650 mysqlhotcopy doesn't work with mysqld in chroot. Patch attached
Description:
Mysqlhot copy fails when the mysqld process has been set-up to run in a chroot jail. The hotcopy script looks for files in the main file tree, not in the chroot.
This happens becuase mysqlhotcopy queries the server for the database directory, but the server gives the reply from inside the chroot, not relative to the real root directory.
How to repeat:
With mysqld set up to run in a jail at /chroot/mysql:
mysqlhotcopy -u user -p topsecret mydatabase /backup_dir
fails with
Cannot open dir '/usr/local/mysql/data/mydatabase'
Suggested fix:
A patch for mysqlhotcopy is included below. It adds the command line option 'chroot' to tell the hotcopy script the root of the chroot jail.
The patch is against Mysql 4.0.17, mysqlhotcopy version 1.20
--- mysqlhotcopy 2003-12-14 21:59:12.000000000 +0000
+++ mysqlhotcopy2 2004-02-05 10:53:56.000000000 +0000
@@ -73,6 +73,7 @@
--resetslave reset the master.info once all tables are locked
--tmpdir=# temporary directory (instead of $opt_tmpdir)
--record_log_pos=# record slave and master status in specified db.table
+ --chroot=# base directory of chroot jail in which mysqld operates
Try \'perldoc $0 for more complete documentation\'
_OPTIONS
@@ -117,6 +118,7 @@
"resetslave",
"tmpdir|t=s",
"dryrun|n",
+ "chroot=s",
) or usage("Invalid option");
# @db_desc
@@ -210,6 +212,9 @@
}
my $datadir = $mysqld_vars{'datadir'}
|| die "datadir not in mysqld variables";
+if ( $opt{chroot} ) {
+ $datadir = $opt{chroot}.$datadir;
+}
$datadir =~ s:/$::;
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Mysqlhot copy fails when the mysqld process has been set-up to run in a chroot jail. The hotcopy script looks for files in the main file tree, not in the chroot. This happens becuase mysqlhotcopy queries the server for the database directory, but the server gives the reply from inside the chroot, not relative to the real root directory. How to repeat: With mysqld set up to run in a jail at /chroot/mysql: mysqlhotcopy -u user -p topsecret mydatabase /backup_dir fails with Cannot open dir '/usr/local/mysql/data/mydatabase' Suggested fix: A patch for mysqlhotcopy is included below. It adds the command line option 'chroot' to tell the hotcopy script the root of the chroot jail. The patch is against Mysql 4.0.17, mysqlhotcopy version 1.20 --- mysqlhotcopy 2003-12-14 21:59:12.000000000 +0000 +++ mysqlhotcopy2 2004-02-05 10:53:56.000000000 +0000 @@ -73,6 +73,7 @@ --resetslave reset the master.info once all tables are locked --tmpdir=# temporary directory (instead of $opt_tmpdir) --record_log_pos=# record slave and master status in specified db.table + --chroot=# base directory of chroot jail in which mysqld operates Try \'perldoc $0 for more complete documentation\' _OPTIONS @@ -117,6 +118,7 @@ "resetslave", "tmpdir|t=s", "dryrun|n", + "chroot=s", ) or usage("Invalid option"); # @db_desc @@ -210,6 +212,9 @@ } my $datadir = $mysqld_vars{'datadir'} || die "datadir not in mysqld variables"; +if ( $opt{chroot} ) { + $datadir = $opt{chroot}.$datadir; +} $datadir =~ s:/$::;