Mysql 資料目錄的遷移方法
阿新 • • 發佈:2019-02-16
附:資料目錄的遷移方法
原目錄:/var/lib/mysql
新目錄:/data/mysql
1)關閉MySQL
/etc/init.d/mysqld stop
2)修改/etc/my.cnf的datadir和socket指向新的目錄:
[plain] view plaincopyprint?
[plain] view plaincopyprint?
4)修改/etc/init.d/mysqld中datadir的路徑
[plain] view plaincopyprint?
[plain] view plaincopyprint?
/etc/init.d/mysqld start
原目錄:/var/lib/mysql
新目錄:/data/mysql
1)關閉MySQL
/etc/init.d/mysqld stop
2)修改/etc/my.cnf的datadir和socket指向新的目錄:
[plain] view plaincopyprint?
- datadir = /data/mysql
- socket = /data/mysql/mysql.sock
[plain] view plaincopyprint?
- mkdir -p /data/mysql
-
chown mysql:mysql /data/mysql
- cp -a /var/lib/mysql/* /data/mysql
4)修改/etc/init.d/mysqld中datadir的路徑
[plain] view plaincopyprint?
- get_mysql_option mysqld datadir "/data/mysql"
[plain] view plaincopyprint?
- else
- DATADIR=/data/mysql
- fi
/etc/init.d/mysqld start