It seems pretty simple on a new install. You can copy the files from /var/lib/mysql to the new location. If you want to initialize it from scratch:
1. set up the datadir variable in /etc/my.cnf under [mysqld] like so:
[mysqld]
datadir = /my/path/to/data/directory
2. You'll need to run the mysql_install_db perl script as the mysql user like so:
su - mysql -c "mysql_install_db --datadir=/my/path/to/data/directory"
or, if you have sudo configured:
sudo -u mysql mysql_install_db --datadir=/my/path/to/data/directory
2b. If you're using selinux, copy the security contexts from /var/lib/mysql recursively like so:
chcon -R --reference=/var/lib/mysql /my/path/to/data/directory
3. Now, you should be able to start MySQL from init or using the service command (on Redhat based distributions)
sudo /etc/init.d/mysql start
or
sudo /sbin/service mysql start
No comments:
Post a Comment