1

I have an EC2 instance and am trying to move the mysql data directory from the default drive to another EBS volume. I moved the mysql directory in /var/lib/mysql to the new destination and then modified the my.cnf file to point the data directory to the new location. I then tried to restart mysql I get the following message.

MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

I am running the default distribution of linux that comes with a new EC2 instance. Below are details to the my.cnf file and mysqld.log. Any suggestions on what I may be doing wrong?

my.cnf

[mysqld]
#datadir=/var/lib/mysql
datadir=/root/appfinder/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Set permissions for folder

chmod -R 777 /root/appfinder/mysql

mysqld.log

110616 18:37:53 mysqld_safe Starting mysqld daemon with databases from /root/appfinder/mysql
/usr/libexec/mysqld: Table 'plugin' is read only
110616 18:37:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: Log scan progressed past the checkpoint lsn 0 37356   
110616 18:37:53  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...  
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 44233
110616 18:37:53  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66$
InnoDB: Apply batch completed
110616 18:37:53  InnoDB: Started; log sequence number 0 44233
5110616 18:37:53 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'host' is read only
110616 18:37:53 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

3 Answers 3

0

I tried to remount my EBS volumes to /myFolder rather than /root/myFolder. This seems to have corrected the permission issues.

0
0

/root/appfinder/mysql director must be owner mysql. For this, chown mysql:mysql /root/appfinder/mysql and chown -R mysql:mysql /root/appfinder/mysql/.

All data files for mysql must be owner mysql.

1
  • I've tried your suggestion. I used chown -R mysql:mysql /root/appfinder/mysql/, which should recursively apply to any items in the directory, but it appears to not work.
    – David
    Jun 17, 2011 at 10:49
0

I had similar problem.

Here are my steps that did work on Ubuntu 12.04 Lts:
Want to move datafiles from /var/lib/mysql to /newdir_path/newdir

  1. sudo mysql stop
  2. sudo rsync -av /var/lib/mysql /newdir_path/newdir
  3. sudo gedit /etc/mysql/my.cnf, change datadir to /newdir_path/newdir
  4. sudo gedit /etc/apparmor.d/usr.sbin.mysqld, change:
      instead of:
      • /var/lib/mysql/ r,
      • /var/lib/mysql/** /rwk
      enter:
      • /newdir_path/newdir/ r,
      • /newdir_path/newdir/** rwk,
  5. sudo /etc/init.d/apparmor restart
  6. (!!!) sudo chown mysql:mysql /newdir_path
  7. sudo start mysql
1
  • Welcome to ServerFault. Thanks for sharing what worked. Please know that gedit may not be installed in all the servers. Sep 18, 2013 at 1:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .