[转]centos7 移动mysql5.7.19 数据存储位置
本文转自:https://blog.csdn.net/chpllp/article/details/78211351
场景:随着数据量的增加,mysql所在的磁盘已占满,需要将data移动到空间较大的盘上。
方法:
1. 关闭mysql服务
- service mysqld stop
2. 将data目录移动到空间较大的盘上
- cp -a /usr/local/mysql/data/ /home/mysqldata/
-a :相当于 -pdr 的意思(参数pdr分别为:保留权限,复制软链接本身,递归复制);
3 . 修改配置文件my.cnf
- ...
- sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
- basedir = /usr/local/mysql
- #datadir = /usr/local/mysql/data
- datadir = /home/mysqldata/data
- #log-error = /usr/local/mysql/data/mysql_error.log
- log-error = /home/mysqldata/data/mysql_error.log
- #pid-file = /usr/local/mysql/data/mysql.pid
- pid-file = /home/mysqldata/data/mysql.pid
- #socket =/usr/local/mysql/data/mysql.sock
- socket =/tmp/mysql.sock
- port=3701
- ...
4. 启动mysql服务
- service mysqld stop
posted on 2018-06-07 09:29 freeliver54 阅读(168) 评论(0) 编辑 收藏 举报