Ir al contenido
Otras versiones

Cargando…

Change MySQL data directory

Esta página aún no está disponible en tu idioma.

Stop the MySQL service:

Terminal window
$ service mysql stop

Create a new folder destination:

Terminal window
$ mkdir /new_path/mysql_data
$ cp -R -p /var/lib/mysql /new_path/mysql_data

Optionally modify the path of the older mysql data store folder location:

Terminal window
$ mv /var/lib/mysql /var/lib/mysql_old

Edit the datadir property into the /etc/mysql/my.cnf configuration file:

Terminal window
$ vim /etc/mysql/my.cnf

Replace the older data store folder path with the newer:

datadir = /var/lib/mysql

to

datadir = /new_path/mysql_data

Enable appamor. Edit the file /etc/apparmor.d/usr.sbin.mysqld:

Terminal window
$ vim /etc/apparmor.d/usr.sbin.mysqld

Replace the older data store folder path with the newer:

/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,

/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

to

/new_path/mysql_data/plugin/ r,
/new_path/mysql_data/plugin/*.so* mr,

/new_path/mysql_data/ r,
/new_path/mysql_data/** rwk,

Start MySQL service:

Terminal window
$ service mysql start

Stop the service:

Terminal window
$ service mysqld stop

Create a new folder destination:

Terminal window
$ mkdir /new_path/mysql_data
$ cp -R -p /var/lib/mysql /new_path/mysql_data

Optionally modify the path of the older mysql data store folder location:

Terminal window
$ mv /var/lib/mysql /var/lib/mysql_old

Edit the datadir property into the /etc/mysql/my.cnf configuration file:

Terminal window
$ vim /etc/mysql/my.cnf

Replace the older data store folder path with the newer:

datadir = /var/lib/mysql

to

datadir = /new_path/mysql_data

Enable appamor.

Terminal window
$ yum install policycoreutils-python
$ getenforce
$ semanage fcontext -a -t mysqld_db_t "/new_path/mysql_data(/.*)?"
$ restorecon -Rv /new_path/mysql_data

Start MySQL service:

Terminal window
$ service mysqld start

Stop the service:

Terminal window
C:\> net stop mysql56

Create a new folder destination:

Terminal window
C:\> robocopy "C:\ProgramData\MySQL\MySQL Server 5.6\data" c:\new_path\mysql_data

Optionally modify the path of the older mysql data store folder location:

Terminal window
C:\> ren "C:\ProgramData\MySQL\MySQL Server 5.6\data" "C:\ProgramData\MySQL\MySQL Server 5.6\data_old"

Edit the datadir property into the C:\ProgramData\MySQL\MySQL Server 5.6\my.ini configuration file:

Replace the older data store folder path with the newer:

datadir = C:\ProgramData\MySQL\MySQL Server 5.6\data

to

datadir = c:\new_path\mysql_data

Start MySQL service:

Terminal window
C:\> net start mysql56