Ask Your Question

Moving default mysql installation directory from yum installation

asked 2015-06-16 16:37:56 -0500

postgres gravatar image

I am using yum to install mysql by puppet. But the default installation directory is /var/lib/mysql. I want to change to /mysql. Is there a way to do that? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-17 22:57:19 -0500

ramindk gravatar image

updated 2015-06-20 14:38:06 -0500

You can't easily move innodb files on disk. Simplest would be to move the dirs and symlink back to /var/lib/mysql without changing the config. If you wanted to deal with it on install some of the following ideas might work.

file { '/mysql':
  ensure => directory,
} ->

file { '/var/lib/mysql':
  ensure => symlink,
  target => '/mysql',
} ->

package { 'mysql': }

Assuming your Mysql package attempts to set itself up once installed you'd want the directories setup first.

You could also try

file { '/mysql':
  ensure => directory,
} ->

exec { 'preinstall my.cnf':
  command => "echo '[mysqld] \n datadir = /mysql' > /etc/my.cnf",
  creates  => '/etc/my.cnf',
} ->

packages { 'mysql': }

Lastly you could use a Mysql package that does not attempt to run on install. IIRC the Percona Mysql packages do not run the mysqld service on install. You could then build the directories and config files you need before starting the daemon which makes the ordering simple. This is the way I handle it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-16 16:36:22 -0500

Seen: 334 times

Last updated: Jun 20 '15