Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am experiencing problems while trying to move my database files to another location. I've tried approaches described here but was unsuccessful. So, here are steps that I tried from the very beginning:

I had an old /var/lib/mysql/ dir with the following contents:

ml/
debian-5.5.flag
ibdata1*
ib_logfile0*
ib_logfile1*
mysql/
mysql_upgrade_info*
performance_schema/
test/

I've copied this structure to another location, say, /media/disk/new_mysql.

Then I've edited file /etc/mysql/my.cnf where I've changed:

datadir = /var/lib/mysql

to

datadir = /media/disk/new_mysql`

The next step was editing /etc/apparmor.d/usr.sbin.mysqld where I've put:

/media/disk/new_mysql/ r,
/media/disk/new_mysql/** rwk,

Then

/etc/init.d/apparmor restart

After that

chown -R mysql:mysql /media/disk/new_mysql
sudo /etc/init.d/mysql start

I'm getting 'failed' status on start. In /var/log/syslog I can find:

Feb  3 19:17:01 s CRON[17952]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb  3 19:17:05 s /etc/init.d/mysql[18008]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Feb  3 19:17:05 s /etc/init.d/mysql[18008]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Feb  3 19:17:05 s /etc/init.d/mysql[18008]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Feb  3 19:17:05 s /etc/init.d/mysql[18008]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Feb  3 19:17:05 s /etc/init.d/mysql[18008]: 

Why does it happen? If I change all preferences in my.cnf and apparmor config back to original values, mysql starts normally.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.