Home > Database > Mysql Tutorial > Mysql Data目录和 Binlog 目录 搬迁的方法_MySQL

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

WBOY
Release: 2016-06-01 13:22:22
Original
1093 people have browsed it

bitsCN.com 如果全过程使用的是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/bitsCN.com

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