Home > Database > Mysql Tutorial > body text

Mysql Data目录和 Binlog 目录 搬迁的方法

WBOY
Release: 2016-06-07 18:05:31
Original
789 people have browsed it

刚开始安装时使用了默认目录,使用一段时间,数据慢慢变在,发现当前设置的目录空间不够时,就要搬迁数据到另一个目录了

如果全过程使用的是Mysql用户,应该可以正常启动。
如果用的ROOT用户,可能不能正常启动,原因是新建的目录权限不对。
可能会这样的错误提示:
/usr/local/mysql/libexec/mysqld: File ‘/home/mysql/mysqllog/binlog/mysql-bin.index' not found (Errcode: 2)

1. stop mysql service 一定要先停止,非常重要。
# /etc/init.d/mysqld stop
2. 修改Mysql配置 My.cnf:

#datadir = /usr/local/mysql/var
#log-bin = /usr/local/mysql/var/binlog/mysql-bin

datadir = /home/mysql/mysqldata
log-bin = /home/mysql/mysqllog/binlog/mysql-bin

3. copy mysql data
# cp -rf /usr/local/mysql/var/* /home/mysql/mysqldata/

4. start mysql service
# /etc/init.d/mysqld start

如果全过程使用的是Mysql用户,应该可以正常启动。
如果用的ROOT用户,可能不能正常启动,原因是新建的目录权限不对。
使用下面命令修改就可以了:
# chown mysql:mysql /home/mysql -R

如果使用了Innodb注意下面修改:

innodb_data_home_dir = /home/mysql/mysqldata/
innodb_log_group_home_dir = /home/mysql/mysqldata/
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!