ต้องการเอา /var/lib/mysql ไปไว้ที่อื่นครับเพราะกลัวเวลาเครื่องมีปัญหาอาจทำให้ข้อมูลหายได้เพราะ /var/lib/mysql อยู่ใน / เลย(ไม่ได้แบ่ง partition แยกออกมา) วิธีแรกที่ผมทำเลยคือ
root@ubuntu:~# mv /var/lib/mysql /data/mysql
root@ubuntu:~# ln -s /data/mysql /var/lib/mysql
ก็คือ move จาก /var/lib/mysql ไปไว้ที่ /data/mysql ผลคือตอน restart mysql มันจะฟ้องว่า
root@ubuntu:~# /etc/init.d/mysql restart
* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [fail]
ไปใน /var/log/syslog ก็เจอ error ประมาณนี้ แล้วจะทำไงดี
root@ubuntu:~# tail -f /var/log/syslog
Nov 9 02:36:29 ubuntu kernel: [ 2394.732730] type=1503 audit(1257752189.048:131): operation="open" pid=5484 parent=5483 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov 9 02:36:30 ubuntu kernel: [ 2395.745479] type=1503 audit(1257752190.061:132): operation="open" pid=5494 parent=5493 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov 9 02:36:31 ubuntu kernel: [ 2396.761345] type=1503 audit(1257752191.080:133): operation="open" pid=5504 parent=5503 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov 9 02:36:31 ubuntu kernel: [ 2396.774493] type=1503 audit(1257752191.092:134): operation="open" pid=5513 parent=5512 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov 9 02:36:31 ubuntu /etc/init.d/mysql[5520]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Nov 9 02:36:31 ubuntu /etc/init.d/mysql[5520]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Nov 9 02:36:31 ubuntu /etc/init.d/mysql[5520]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Nov 9 02:36:31 ubuntu /etc/init.d/mysql[5520]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
(more…)