ubuntu下mysql使用ntfs格式的datadir問題

來源:互聯網
上載者:User

先敘述一下背景,本機硬碟2塊,

120G SSD  = 60(linux ext4) + 60 (win7 NTFS)

2T 機械硬碟  = 600G NTFS + 600G NTFS + 700G NTFS

當初為了照顧win7對於ext分區相容性的問題,將2T的3個分區都設為了NTFS的,如今就遇到了麻煩

由於mysql要處理大資料,SSD不夠用,於是要轉移datadir,開始使用的是ln的辦法,但是怎麼搞都不行

後來發現,ntfs分區的檔案的owner不能更改,即使用chown更改了(沒有報錯),實際owner還是當前分區的掛載者(root)

試圖解決這個問題,於是修改了fstab,將根據 /dev/sda1 這種格式的掛載改為UUID掛載,但是還是沒有解決這個問題

於是改了datadir之後重啟mysql總是報錯,

zs@linux:/media/linux/lnRoot$ sudo /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
start: Job failed to start

於是上網搜啊搜……………..

ntfs掛載在ubuntu下面的檔案許可權都是777的,具體操作過程遇到的問題和解決如下:

 1. 修改 /etc/mysql/my.cnf

 代碼如下 複製代碼

datadir        = /var/lib/mysql

改為

datadir        = /media/MyDocuments/mysql

 嘗試重啟mysql

 代碼如下 複製代碼

sudo /etc/init.d/mysql stop

sudo /etc/init.d/mysql start

結果mysql怎麼也重啟不來

 查看日誌,/var/log/mysql/error.log,如下:

100819 15:10:20 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
100819 15:10:20 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
100819 15:10:20  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

查了很久,基本都是說apparmor的問題,其實這個在my.cnf裡面也有提到過了,

 代碼如下 複製代碼
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor, you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.

ok,這樣的話,就明白很多了,修改/etc/apparmor.d/usr.sbin.mysqld即可。

 代碼如下 複製代碼
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

改為

 代碼如下 複製代碼
#/var/lib/mysql/ r,
#/var/lib/mysql/** rwk,
/media/MyDocuments/mysql/ r,
/media/MyDocuments/mysql/** rwk,

再運行一下:

 代碼如下 複製代碼
/etc/init.d/apparmor reload
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.