Database directory location

44 views
Skip to first unread message

Vincent Arsenault

unread,
Apr 15, 2024, 1:40:00 PMApr 15
to AtoM Users
Hi everyone, 
I'm wondering if there is a way to install the database directory at a specific location on install of mysql. Or do I need to install it normaly and then move the data base directory after the installation. If so is there a how to or a documentation somewhere on that ? 
Atom will be install on a linux (Focal Fossa).
In short, I wanna change "/var/lib/mysql" (that would be default directory for the sql database) to be on a hardrive instead.

thanks a lot ! 

Jim Adamson

unread,
Apr 19, 2024, 11:51:51 AMApr 19
to ica-ato...@googlegroups.com
Hi,

A quick look at the output of debconf-get-selections | grep mysql suggests it wouldn't be possible to set the data directory for the installation using a debconf-set-selections <<< "..." command before running apt install -y mysql-server. The fact that this was asked here with no answer suggests to me that it's probably not possible.

You've probably worked out by now that you can change the location after installation by stopping the mysql service and editing /etc/mysql/mysql.conf.d/mysqld.cnf:

datadir       = /var/lib/mysql

Edit to the path of your choosing, move the files in /var/lib/mysql to your new location and then restart mysql.

Another way would be to stop mysql, move the files in /var/lib/mysql to your new location and replace the mysql directory in /var/lib with a symlink to your new data location. But there's probably no good reason to do that above setting the location in mysqld.cnf.

Thanks, Jim

--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/6c3c56a6-9f1d-4c0e-89cf-379fc852c9e8n%40googlegroups.com.


--
Jim Adamson
Systems Administrator/Developer
Facilities Management Systems
IT Services
LFA/023 | Harry Fairhurst building | University of York | Heslington | York | YO10 5DD

Vincent Arsenault

unread,
Apr 19, 2024, 12:00:41 PMApr 19
to AtoM Users
Hi Jim

thanks for the reply. I'm currently working on that at the moment. As you have said. I'm now trying to change the location of the data directory after the installation as it seems to be the only to achieve that.
I have follow multiple "how to" that all suggest the same way as you are. 

I always get the same error when I try to start mysql back ;
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service for details.

I have change 
datadir = /home/atom/Documents/myDatabase
for
datadir = /home/atom/Documents/myDatabase/mysql

without any luck as well.
This is where I'm stock as for now.
If you have any clue on why I get that, it would be awsome, if not thanks anyway ! 

Jim Adamson

unread,
Apr 19, 2024, 12:11:12 PMApr 19
to ica-ato...@googlegroups.com
What does systemctl status mysql say? Also you could check /var/log/mysql/error.log.

How did you move the files over to the new location? It's possible the ownership was changed as part of that process, so you might need to run chown -R mysql:mysql /home/atom/Documents/myDatabase/mysql

Thanks, Jim

Reply all
Reply to author
Forward
0 new messages