Ubuntu下完美实现迁移MySQL数据库位置
作者:hebedich 时间:2024-01-16 15:39:26
考虑到数据安全问题,准备把服务器上的数据库迁移到刚刚挂载的云硬盘上,研究一下,这个方法是最靠谱的,分享之!
首先建立数据库即将迁移到的目录
mkdir /media/hdb1/db
复制linux下原数据到新目录下
cp -dpR /var/lib/mysql/* /media/hdb1/db
给新目录重命属性
chown mysql:mysql /media/hdb1/db
修改文件"/etc/apparmor.d/usr.sbin.mysqld“
sudo vim /etc/apparmor.d/usr.sbin.mysqld
把
/var/lib/mysql r,
/var/lib/mysql/** rwk,
改成
/media/hdb1/db r,
/media/hdb1/db/** rwk,
修改目录
sudo vim /etc/mysql/my.cnf
如datadir = /var/mysql换成datadir = /media/hdb1/db
再开服务器
sudo /etc/init.d/apparmor restart sudo /etc/init.d/mysql restart
大功告成!!!!
以上所述就是本文的全部内容了,希望大家能够喜欢。
标签:Ubuntu,迁移,MySQL,数据库
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python十进制和二进制的转换方法(含浮点数)
2021-04-03 02:26:24
python字典和json.dumps()的遇到的坑分析
2023-07-27 22:03:29
![](https://img.aspxhome.com/file/2023/3/85213_0s.png)
最新Python APScheduler 定时任务详解
2021-05-03 21:58:53
![](https://img.aspxhome.com/file/2023/3/69503_0s.png)
带你学习MySQL执行计划
2024-01-18 12:34:37
sqlserver 三种分页方式性能比较[图文]
2011-09-30 11:16:20
tensorflow 限制显存大小的实现
2023-03-04 02:19:59
Python3.7将普通图片(png)转换为SVG图片格式(网站logo图标)动起来
2021-09-26 00:05:53
![](https://img.aspxhome.com/file/2023/3/115723_0s.png)
能否推荐一个论坛用的数据库结构?
2009-11-01 18:09:00
Go语言编程中对文件读写的基本方法整理
2023-06-24 09:31:07
pytorch 可视化feature map的示例代码
2021-10-21 13:35:49
python实现梯度下降算法
2023-09-22 19:09:39
![](https://img.aspxhome.com/file/2023/7/105337_0s.png)
asp 动态数组 提供Add、Insert、Remove、RemoveAt、Search等方法。
2011-03-17 11:10:00
Python文件操作和异常处理的方法和技巧
2021-05-22 10:54:10
Mysql 获取表的comment 字段操作
2024-01-19 12:12:28
![](https://img.aspxhome.com/file/2023/0/122870_0s.jpg)
重构中的模块化设计:样式的作用域
2010-04-23 14:42:00
基于Tensorflow搭建一个神经网络的实现
2024-01-02 06:09:35
![](https://img.aspxhome.com/file/2023/0/77620_0s.png)
sql server 创建临时表的使用说明
2024-01-16 18:30:23
JS踩坑实战之19位数Number型精度丢失问题详析
2024-04-10 10:44:23
![](https://img.aspxhome.com/file/2023/6/136976_0s.jpg)
git验证线上的版本是否符合预期
2023-03-04 16:24:09
![](https://img.aspxhome.com/file/2023/4/132414_0s.png)
python之cur.fetchall与cur.fetchone提取数据并统计处理操作
2023-11-30 05:34:06
![](https://img.aspxhome.com/file/2023/1/77681_0s.jpg)