Moving MySQL or Percona db files to another disk

Moving MySQL or Percona database files  to another disk

Phase I

  • add disk to vm
  • fdisk newdisk
  • mkfs newdisk
  • create new mountpoint
  • add newdisk to fstab
  • reboot

Phase II

  • service mysql stop
  • mkdir /storage/mysql
  • mv /var/lib/mysql/* to /storage/mysql
  • DO NOT DELETE /var/lib/mysql it is still used for sockets
  • vi /etc/my.cnf
  • [mysqld]
  • datadir=/storage/mysql
  • socket=/var/lib/mysql/mysql.sock

Phase III

  • chown -R mysql:mysql /storage/mysql
  • turn off selinux
  • service mysql start

See

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s