You are not logged in.

#1 2014-06-27 14:56:22

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Changing data directory for mysql(mariadb)

I want to shift my mysql default data directory from /var/lib/mysql to a folder in my home folder, because the databases I will be creating will be over 100Gb, and my root folder is on a 32 Gb SSD. Could anyone please give me proper detailed steps on how to accomplish this. I tried to do this once following some blog online and it messed up my whole mysql installation(I had to reinstall everything).

Offline

#2 2014-06-27 15:30:54

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Changing data directory for mysql(mariadb)

I'd create a partition or directory on the big drive and mount it to /var/lib/mysql in /etc/fstab. Much easier!

Scott

Offline

#3 2014-06-27 15:47:40

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Re: Changing data directory for mysql(mariadb)

This is kinda temporary though. Say I follow your advice, do I just create a partition and then mount it in fstab? No permission changes etc ?

Offline

#4 2014-06-27 16:16:06

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Changing data directory for mysql(mariadb)

You have make sure permissions are initially set correctly, but then it will just be automatically mounted by fstab.one time setup, then you don't have to think about it anymore.

Offline

#5 2014-06-27 16:27:38

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Re: Changing data directory for mysql(mariadb)

I'm not entirely sure how to go about it. There is a /var/lib/mysql directory. Also, I just noticed that mysqld.sock and mysqld.pid is in a different directory(/run/mysqld). How di I set the permissions correctly?

Offline

#6 2014-06-27 16:30:33

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: Changing data directory for mysql(mariadb)

You must have searched really hard before asking here!

Have a look at datadir / socket / pid_file @ my.cnf

Offline

#7 2014-06-28 03:08:23

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Re: Changing data directory for mysql(mariadb)

In my my.cnf file there is no datadir option the socket and pid options point to /run/mysqld. I'm a little confused because of this. There is a datadir option separately for InnoDB, but it is commented out. Also I am planning to use MyISAM.

Offline

#8 2014-06-29 09:17:49

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: Changing data directory for mysql(mariadb)

Why would datadir be for innodb only? https://dev.mysql.com/doc/refman/5.0/en … ld_datadir

Offline

#9 2014-06-29 13:58:35

gvenkat1994
Member
Registered: 2014-04-13
Posts: 34

Re: Changing data directory for mysql(mariadb)

No before the datadir line there is a line that says Uncomment the following lines if you are using InnoDb. That is what confused me. Also, when I changed that option it doesn't have any effect. The data is still stored in /var/lib/mysql

Offline

#10 2014-11-06 09:27:45

omnibrain
Member
Registered: 2013-11-08
Posts: 4

Re: Changing data directory for mysql(mariadb)

I'm having the same issue. Any help would be greatly appreciated.

Offline

#11 2015-05-03 17:48:27

lufti
Member
Registered: 2015-01-22
Posts: 6

Re: Changing data directory for mysql(mariadb)

I hope this aint counting as necromancy.

I found this thread but I also found the solution, so if anyone stumble into the same issues.

Here the basics:

If you do not use the default location, just put into /etc/mysql/my.conf (or whereever your conf is):
datadir=/path/to/datadir

Otherwise, it will always default to /var/lib/mysql (maybe this will change)

Have a nice day,
lufti.

Offline

#12 2015-08-22 22:13:32

nadman10
Member
From: Erie, PA
Registered: 2005-10-15
Posts: 201

Re: Changing data directory for mysql(mariadb)

lufti wrote:

I hope this aint counting as necromancy.

I found this thread but I also found the solution, so if anyone stumble into the same issues.

Here the basics:

If you do not use the default location, just put into /etc/mysql/my.conf (or whereever your conf is):
datadir=/path/to/datadir

Otherwise, it will always default to /var/lib/mysql (maybe this will change)

Have a nice day,
lufti.

I think he already tried that. I am in the same boat and am still having issues. Even after adding a "datadir" entry, mysqld is still trying to use /var/lib/mysql

Offline

Board footer

Powered by FluxBB