There are a lot of answers on Google about moving a MySQL datadir, but the gist of it on linux is:
It can be advantageous to move the directory on the supervisor which contains the SQL database files from the root volume or C: drive to a filesystem on a dedicated disk. This should be a separate physical disk, not just another partition on the same disk as other partitions, otherwise you'll get almost no benefit.
Linux
- Be logged into the Supervisor as the root user
- Stop the Supervisor service: /etc/init.d/
service supervisor stop
- Stop the mysql postgresql server: /etc/init.d/mysqld
service postgresql-pfx stop
- Copy the current datadir over to the new location ensuring that you preserve ownership and permissions:
cp -rP /
varusr/
liblocal/
mysqlpfx/pgsql/data /newpath/
mysqlpgsql/data
- Rename the current datadir so that it won't be found by mistake, but leave it in place so you have a fallback plan:
mv /
varlusr/
liblocal/
mysqlpfx/
varpgsql/
lib/mysqldata /usr/local/pfx/pgsql/data.MOVED
- Edit the /etc/my.cnf, copy the
datadir
line, comment out the original as a backup (part 2 of the fallback plan), and edit the uncommented line to point to the new location - Start the mysql server: /etc/init.d/mysqld Make a backup copy of the startup script, /usr/local/pfx/qube/utils/pgsql/startdb.sh , then edit it by changing the PGSQL_DATA_DIR to point to the new data directory.
Optionally, you may also want to change the PGSQL_LOG to point to a new log location. - Make a backup copy of the stop script, /usr/local/pfx/qube/utils/pgsql/stop.sh , then edit it by changing the PGSQL_DATA_DIR to point to the new data directory.
- Start the postgresql server:
service postgresql-pfx start
- Check that the new datadir is the one being used:
mysql -u root -e "SHOW variables like 'datadir'"
+---------------+-----------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------+
| datadir | /usr/local/MySQL-5.1.44-MACOSX-Universal/var/ |
+---------------+-----------------------------------------------+
If it looks good, start the Supervisor service:
/etc/init.d/supervisor start
/usr/local/pfx/pgsql/bin/psql -p 50055 -U pfx -d pfx -c "SHOW data_directory"
If it looks good, start the Supervisor service:
service supervisor start
Mac
- Run the following commands in a terminal.
Stop the Supervisor service:
sudo launchctl stop com.pipelinefx.supervisor- Stop the postgresql server:
sudo launchctl stop com.pipelinefx.postgresql
- Copy the current datadir over to the new location ensuring that you preserve ownership and permissions:
sudo cp -rP /Applications/pfx/pgsql/data /newpath/pgsql/data
- Rename the current datadir so that it won't be found by mistake, but leave it in place so you have a fallback plan:
sudo mv /Applications/pfx/pgsql/data /Applications/pfx/pgsql/data.MOVED
- Make a backup copy of the launchd plist file,
/Library/LaunchDaemons/com.pipelinefx.postgresql.plist
, then edit it by changing/Applications/pfx/pgsql/data
to the new data directory.
Optionally, you may also want to change/Applications/pfx/pgsql/pgsql.log
to new log location. - Start the postgresql server:
sudo launchctl start com.pipelinefx.postgresql - Check that the new datadir is the one being used:
/Applications/pfx/pgsql/bin/psql -p 50055 -U pfx -d pfx -c "SHOW data_directory"
If it looks good, start the Supervisor service:
sudo launchctl start com.pipelinefx.supervisor
Windows
- stop the qubesupervisor service
- stop the postgresql-pfx service
- move the C:\Program Files\pfx\pgsql\data directory to the new directory, e.g., D:\qube\data
- run the following command on a command prompt to first unregister the postgresql-pfx service:
"C:\Program Files\pfx\pgsql\bin\pg_ctl" unregsiter -N postgresql-pfx
- run the following command (substitute the data directory, "D:\qube\data") to register the postgresql-pfx service with the new directory:
"C:\Program Files\pfx\pgsql\bin\pg_ctl" regsiter -N postgresql-pfx -S auto -U pfx -P Qub3!R0x! -D D:\qube\data
("Qub3!R0x!" is the default password for the pfx user-- substitute appropriately, if you've changed it) - start the postgresql-pfx service
- test that the PostgreSQL server sees the database in its new location by running:
"C:\Program Files\pfx\psql" -p 50055 -U pfx -d pfx -c "SHOW data_directory".
- start the qubesupervisor service