My system disk is too small, the database file is too large, added a new hard drive, mounted under / opt / extra. So I want to migrate to the new database file to mount the disk up. Specific methods are as follows.
- Close mariadb
sudo service mariadb stop
- Create a directory to store the database file / opt / extra / mariadb and change its permissions in / opt / extra
chown -R mysql:mysql /opt/extra/mariadb
- Home position database / lower var / lib / mysql, copy the past to this directory.
cp -a /var/lib/mysql /opt/extra/mariadb
- To the directory /etc/mysql/mariadb.conf.d modified 50-server.cnf, 50 in front of this may not be the same. Datadir changed to the value / opt / extra / mariadb / mysql
- It can restart mariadb