MySQL 轉移資料檔案

來源:互聯網
上載者:User

Ubuntu 12.04下如何轉移呢?這篇討論給了大致的方向:

http://askubuntu.com/questions/224/how-to-i-move-mysql-data-files-onto-different-partition

預設資料檔案路徑是/var/lib/mysql 目錄,但是磁碟空間太小,我想放到/home/data/mysql目錄下。

首先停止mysql 服務

service mysql stop

然後複製/var/lib/mysql/目錄下所有檔案到/home/data/mysql/目錄下

cp -r /var/lib/mysql/* /home/data/mysql/
放開許可權

chmod -R 777 /home/data/mysql

修改/etc/mysql/my.cnf檔案mysqld一節的配置:

datadir         = /home/data/mysql

修改檔案/etc/apparmor.d/tunables/alias內容:

alias /var/lib/mysql/ -> /home/data/mysql/,

啟動 mysql 即可。原來的資料檔案此時可以刪除了。



相關文章

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.