How to move a folder to store mysql data to a removable hhd drive?

Is Linux Mint 17.3
the data are now stored in /var/lib/mysql
how to transfer them for example to /media/user/HDD/mysql
Already tried lots of things and changed the datadir in confine and articles but still can not start mysql
Who faced and then I ssd to 120gb for system and mysql data is 30GB and it will grow
June 10th 19 at 14:51
2 answers
June 10th 19 at 14:53
And who prevents to mount the external drive to /var/lib/mysql ?
I need one directory to use an external drive, not the whole disk - nikita.Stracke commented on June 10th 19 at 14:56
And what should be the filesystem on the disk? Have SSD ext4 - nikita.Stracke commented on June 10th 19 at 14:59
Of course, I can split this HDD drive, but under which file system to share and an example of mounting the /var/lib/mysql if not more difficult - nikita.Stracke commented on June 10th 19 at 15:02
service mysqld stop
mkdir /media/user/HDD/mysql
chown mysql:mysql /media/user/HDD/mysql
mv /var/lib/mysql/* /media/user/HDD/mysql/
rm /var/lib/mysql
ln-s -f /mnt/user/HDD/mysql/ /var/lib/mysql/
service mysqld start

I recommend to understand and understand what each does. Is the transfer of the server data directory on the SSD and create symlink at the same location.

/etc/fstab:
/dev/sdb1 /var/lib/mysql ext4 defaults 0 0

and this is the entry in fstab about mounting the external drive to the desired directory.

But in principle you need the first option - Reb commented on June 10th 19 at 15:05
I did =] did as you wrote above, and here are the errors in the log
https://pastebin.com/6DpCMgK1 - nikita.Stracke commented on June 10th 19 at 15:08
June 10th 19 at 14:55
Mount the disk, copy the files from /var/lib/mysql. Then in the file /etc/mysql/mysql.conf.d/mysqld.cnf change the path /var/lib/mysql to the new folder path, then in /etc/apparmor.d/usr.sbin.mysqld lines
# Allow data access dir
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

change to a new path, restart apparmor and run database
Or after copying the files where it is necessary to make a symlink in there, and then edit the configs don't have. - nikita.Stracke commented on June 10th 19 at 14:58
, apparmor anyway you will swear it is necessary to prescribe in it the real way - nikita.Stracke commented on June 10th 19 at 15:01
,
Guys I did it, before I ask question I googled many times
Which file system must have disk?
sudo service apparmor restart those services do not - nikita.Stracke commented on June 10th 19 at 15:04
to Google I also know how but the problem is not solved
did everything you said here is the result https://pastebin.com/6DpCMgK1 - Reb commented on June 10th 19 at 15:07
data was transferred or not? if you just ordered and restarted it before this run mysql_upgrade to create the system database files - nikita.Stracke commented on June 10th 19 at 15:10
of course endured, I'm with this problem for 2 day fight, in all the articles the same, but does not help - Gonzalo.Hane39 commented on June 10th 19 at 15:13
chmod -R mysql:mysql /new/path done? - Franz.Waters16 commented on June 10th 19 at 15:16

Find more questions by tags MintDatabasesMySQLLinuxDatabase administration