Mysql日志文件默认路径的修改方法(Mysql binlog relocate)
来源:互联网 发布:sony xperia xz1 知乎 编辑:程序博客网 时间:2024/06/13 08:59
Moving MySQL data and logs on Ubuntu to a new location the hard way
There's lots of information online on how to move MySQL data and logs to a new location but I had to use a combination of several guides in order to get it fully working. This is a reference for me if I ever need to do it again or for anyone else that may find it useful.
Also, if I ever have to do it again, I would definitely choose a much simpler way of just binding the new directory to the default one in /etc/fstab. Something like:
echo "/new/path/for/mysql/data /var/lib/mysql none bind" | sudo tee -a /etc/fstab
as it eliminates all problems with apparmor and having to manually update binary log index files. This way you don't need to do steps 3 through 6, though you have to move the data and not copy in this case.
Step 1: stop mysql
sudo service mysql stop
Step 2: copy/move the data
sudo cp -rp /var/lib/mysql/ /new/path/for/mysql/data/sudo cp -rp /var/log/mysql/ /new/path/for/mysql/logs/
Step 3: edit mysql config replacing old paths with new ones
sudo nano /etc/mysql/my.cnf
Step 4: edit apparmor config for mysql replacing old paths with new ones
sudo nano /etc/apparmor.d/usr.sbin.mysqld
Step 5: edit mysql binary log index file replacing old paths with new ones
sudo nano /new/path/for/mysql/logs/mysql-bin.index
Step 6: restart apparmor to make sure that it picks up the new config
sudo service apparmor restart
Step 7: finally, start mysql and pray that everything works
sudo service mysql start
亲测有效
转载地址: https://ivan-site.com/2011/01/moving-mysql-data-and-logs-on-ubuntu-to-a-new-location-the-hard-way/
方法2
利用 Mysql Utilities -- mysqlbinlogmove
Usage.eg
- Stop the running MySQL server.
- Start the mysqlbinlogmove utility and specify the source directory of the binary log files and the target directory.
shell> mysqlbinlogmove --binlog-dir=/var/lib/mysql \ /mysql/server/binlogs## Moving bin-log files...# - server-bin.000001# - server-bin.000002# - server-bin.000003# - server-bin.000004# - server-bin.000005# - server-bin.000006# - server-bin.000007# - server-bin.000008# - server-bin.000009# - server-bin.000010# - server-bin.000011##...done.#
- Restart the MySQL server with the new value for the --log-bin option: --log-bin=/mysql/server/binlogs/server-bin.
0 0
- Mysql日志文件默认路径的修改方法(Mysql binlog relocate)
- MySQL的binlog日志
- mysql的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- mysql 的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- MySQL的binlog日志
- 修改 mysql-binlog 二进制日志文件至其它目录
- MySql的binlog日志操作(一)
- MySQL的binlog文件
- mysql删除binlog日志及日志恢复数据的方法
- 基于LinkedHashMap实现LRU缓存调度算法原理
- 数字签名是什么?
- Celery 和 RabbitMQ
- [cc]18.9中位数
- C++11,使简单的事情简单
- Mysql日志文件默认路径的修改方法(Mysql binlog relocate)
- jquery学习 - 对动态创建的元素进行事件响应(bind, live, delegate)
- Soot学习笔记(1)-Adding profiling instructions to applications
- CentOS查看CPU、内存、网络流量和磁盘 I/O【详细】
- 删除链表中重复元素
- tomcat端口8080被占的处理方法
- C实现-CPP的-封装
- 黑马程序员-IO流学习笔记-1
- C实现-CPP的-继承