snippetsqlMinor
How to set datadir to different values based on the hostname in my.cnf?
Viewed 0 times
datadirthecnfdifferenthostnamebasedhowvaluesset
Problem
How to set
datadir to different values based on the hostname in my.cnf? I want to use the same my.cnf file on a Linux machine and a Mac OS X machine where the datadir should have different values.Solution
A simple solution for that would be to keep the
On you linux host, you would:
Add permissions to this folder for mysql user:
my.cnf file identical, and use symlinks on your machine sto point to whatever directory you want the data to be in. For example, assuming you my.cnf contains this:[mysqld]
datadir=/mysql_dataOn you linux host, you would:
cd /
ln -s /var/lib/mysql mysql_dataAdd permissions to this folder for mysql user:
chown mysql:mysql /mysql_dataCode Snippets
[mysqld]
datadir=/mysql_datacd /
ln -s /var/lib/mysql mysql_datachown mysql:mysql /mysql_dataContext
StackExchange Database Administrators Q#14993, answer score: 2
Revisions (0)
No revisions yet.