0

Question in a title, how can I install MySQL DB to a certain partition in a Linux (Ubuntu)? I don't want to move my DB after installing, I want to install it certain partition at once

1 Answer 1

-1

By default, MySQL (and MariaDB) stores database files in /var/lib/mysql. The Data Directory is controlled by the --datadir option in /etc/mysql/my.cnf. So you can edit your config file and set an alternative location using the datadir option:

datadir=/new/partition

Alternatively, you could setup a new partition specifically for the default location of /var/lib/mysql when you go to install the operating system. So you would create a separate partition specifically for the MySQL directory. Then in your /etc/fstab file, you'd add the new partition and point it to /var/lib/mysql. For example, if you have 1 partition now, and 1 swap partition, you'd add the 3rd partition, and your fstab file might look like this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/sda       /               ext4    errors=remount-ro 0       1
/dev/sdb                                 none            swap    sw              0       0
/dev/sdc       /var/lib/mysql   ext4    errors=remount-ro 0      1

See the following for a few resources: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_datadir and https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .