Question

Unable to To Move a MySQL Data Directory to a New Location on Ubuntu 18.04

I’m trying to setup a personal clound server on my home desktop with Ubuntu 18.04. I have an external 10TB hdd attached and would like to move the data that mysql stores on to the drive because I plan to use it as a storage/backup for multiple machines in the house. I followed this tutorial and when I try to restart mysql I get an error and after using

journalctl -xe

I get this output

-- Unit mysql.service has finished shutting down.
Feb 02 22:10:08 Skynet-Desktop systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has begun starting up.
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: mysqld: Can't change dir to '/media/Skynet/10TB/mysql/' (Errcode: 13 - Permission denied)
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.592734Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.592814Z 0 [Warning] Can't create test file /media/Skynet/10TB/mysql/Skynet-Desktop.lower-test
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.592835Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-0ubuntu0.18.04.1) starting as process 17283 ...
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594232Z 0 [Warning] Can't create test file /media/Skynet/10TB/mysql/Skynet-Desktop.lower-test
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594238Z 0 [Warning] Can't create test file /media/Skynet/10TB/mysql/Skynet-Desktop.lower-test
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594454Z 0 [ERROR] failed to set datadir to /media/Skynet/10TB/mysql/
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594458Z 0 [ERROR] Aborting
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594468Z 0 [Note] Binlog end
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: 2020-02-03T03:10:08.594490Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Feb 02 22:10:08 Skynet-Desktop mysqld[17281]: Initialization of mysqld failed: 0
Feb 02 22:10:08 Skynet-Desktop systemd[1]: mysql.service: Control process exited, code=exited status=1
Feb 02 22:10:08 Skynet-Desktop systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 02 22:10:08 Skynet-Desktop systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has failed.

There’s more in the error, but this is the important part. If anyone needs to see the rest let me know and I’ll paste it in, but I don’t want to waste space in this question.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @Pachuca,

Looking at the error_log it seems it’s finding a path -

/media/Skynet/10TB/

Should it be there? If yes, please make sure you’ve actually set the correct permissions, I would assume that’s the source of the problem.

Regards, KDSys