MySQL Database migration Ubuntu14.04

Source: Internet
Author: User

1. Stop the database service

sudo service MySQL stop

2. Create a Data Migration destination folder (it should actually be mounted on a new hard disk)

Cd/var/lib

Ls-l

drwx------6 MySQL mysql 4096 January 9 09:26 mysql/#文件夹权限700, only MySQL users can access

sudo mkdir/mysqldata #创建目录

sudo chown-vr mysql:mysql/mysqldata/#更改所属组与用户, making it consistent with the original MySQL directory

#建议不使用rm移动目录, but use CP to avoid accidents

Su #切换到root账号, if you do not switch directly using root, you will be prompted to CP: Unable to get "/var/lib/mysql/*" File Status (STAT): There is no file or directory

cp-av/var/lib/mysql/*/mysqldata/

Exit # Cut back to the original account

sudo vim/etc/mysql/my.cnf #其中datadir为mysql路径, change to New path address

sudo vim/etc/apparmor.d/usr.sbin.mysqld #找到/var/lib/mysql commented out and changed to a new path

sudo service AppArmor Reload

sudo service MySQL restart

MySQL Database migration Ubuntu14.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.