Last Updated: February 25, 2016
·
816
· daraff

move mysql data to another folder in 5 minutes (Ubuntu)

I ran shortly into the problem, that i had to move my mysql database for development to another directory (a new drive).

My first intention was to find a config and change it, or create some symlink. After i needed some hours to solve the problem, i want to share the steps.

As long as you move the data to the same partition, this article can help you perfectly
http://article.my-addr.com/?show=linux_ubuntu_change_datadir-move_mysql_database_to_other_path

But if you want to move your mysql data folder to another drive, you have to work with mount
(Thanks to this article, where i get the idea - http://aws.amazon.com/articles/1663?_encoding=UTF8&jiveRedirect=1)

sudo service mysql stop
mkdir -p /new_data_folder/
sudo mv /var/lib/mysql /new_data_folder/
sudo mkdir /var/lib/mysql
echo "/new_data_folder/mysql /var/lib/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/lib/mysql
sudo service mysql start

1 Response
Add your response