Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to install mysqld via apt-get and have it a non default path for the data files?

I know I can install it with the defaults and then move stuff (I've done that) but then I have about a dozen different places I need to update things (4-5 in my.cnf, 6-8 for app-armor, and I think there was somethings else that I'm forgetting).


Edit: I'm assuming/hoping that the relevant config files are all generated at install time rather than being hard coded as static content. Assuming that, what I need is a way to have apt-get pass on the flags to adjust the variables used to specify the relevant paths.

share|improve this question

3 Answers 3

Depending on your distribution you can perhaps overwrite mysql settings in a file /etc/mysql/conf.d/... ?

share|improve this answer
    
That file doesn't exist until after mysql has been installed, at which point everything has been set up with stuff in the wrong places... –  BCS Jan 18 '11 at 21:47
    
Yes, but why not just create this directory and put your config in there? When installing mysqld it should pick up this config on the very first start, shouldn't it? –  m.sr Jan 19 '11 at 11:23
    
Part of the issue is that there is several different places the path ends up (and I'm not sure I've found them all) the rest is that doing that would prevent future releases of MySQL from having any say in the config. –  BCS Jan 19 '11 at 15:16
    
I don't really understand what you mean. If don't know the path to your data files, you have an other problem ... ;). If you know the path to your data files, create a file in /etc/mysql/conf.d/ with (an only with) the parameters for mysqld, which you want to overwrite. When mysqld starts, it first reads the /etc/mysql/my.cnf and then files in /etc/mysql/conf.d/ and "rewrites" the given settings. That's all ... –  m.sr Jan 19 '11 at 15:47
    
Ah! I didn't know about the conf.d bit. But that still doesn't solve the problem of finding the rest of the places that the path should go (/etc/apparmor.d/usr.sbin.mysql for a start) –  BCS Jan 19 '11 at 19:01

You'll have to make your own mysql packages if you want to make them install with special paths just for you. It would be easier to use symlinks or bind mounts to move whatever it is you want to move to wherever it is you want it to go.

Otherwise, your choices are the right way of building a custom package from source and the very, very wrong way of hacking apart an existing package with ar, changing all the paths and configuration files, then putting it back together again.

share|improve this answer

All you mentioned was apt, and not any specific distribution.

I just performed a quick inspection of the preinst/postinst scripts on a Debian Lenny mysql-server deb source. These folders are hard coded as part of the included management scripts and default configuration file. There is no magical tool on Debian Lenny, and I suspect others to redirect the data/log folders before the install is done. Debconf is not used in the version of the Mysql package I looked at, but this tool is commonly used to set preferences for other packages.

So the short answer, is that you probably will need to fix things post install. If you grab the package source and take a look at the scripts in /var/lib/dpkg/info/mysql* you should get a good idea of what exactly needs to be changed.

share|improve this answer
    
Is there are least a way to make said edits before the server gets started? "Install all the files, but let me do the initialization later." –  BCS Jan 19 '11 at 15:53
    
You can just delete the old files, when you point MySQL into the new directories it will need the initialization again. MySQL works based on config files, caches and such, so the executable won't remember anything. –  Frands Hansen Mar 12 '11 at 5:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.