Ubuntu修改MySQL数据库datadir目录

本文详述了如何在Ubuntu系统中将MySQL数据库的datadir目录从旧位置迁移到新位置,涉及停服、备份、新建目录、移动数据、修改配置文件、更新apparmor配置及重启服务等步骤。确保在操作前对数据进行备份,成功迁移后通过验证确认服务正常运行。
摘要由CSDN通过智能技术生成

概述

本文描述了在Ubuntu 16.04系统下修改mysql-server-5.7数据库datadir目录的详细步骤。目标:将数据库目录datadir/var/lib/mysql修改到/home/database/mysql

系统信息:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

$ uname -a
Linux Ubuntu 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

mysql-server版本:

Server version: 5.7.11-0ubuntu6 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

步骤

以下步骤需要停止mysql服务并假设用户拥有管理员权限。

一、停止mysql服务

sudo service mysql stop
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值