Switch storage locations of database mariadb

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.

  1. Close mariadb 
    sudo service mariadb stop
  2. 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
    
  3. Home position database / lower var / lib / mysql, copy the past to this directory.
    cp -a /var/lib/mysql /opt/extra/mariadb
  4. 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
  5. It can restart mariadb

Guess you like

Origin www.cnblogs.com/gelandesprung/p/12111223.html