MySQL Change Data Directory
Stop MySQL using the following command:
sudo /etc/init.d/mysql stop
Copy the existing data directory (default located in
/var/lib/mysql
) using the following command:sudo cp -R -p /var/lib/mysql /newpath
edit the MySQL configuration file with the following command:
sudo gedit /etc/mysql/my.cnf # or perhaps /etc/mysql/mysql.conf.d/mysqld.cnf
Look for the entry for
datadir
, and change the path (which should be/var/lib/mysql
) to the new data directory.In the terminal, enter the command:
sudo gedit /etc/apparmor.d/usr.sbin.mysqld
Look for lines beginning with
/var/lib/mysql
. Change/var/lib/mysql
in the lines with the new path.Save and close the file.
Restart the AppArmor profiles with the command:
sudo /etc/init.d/apparmor reload
Restart MySQL with the command:
sudo /etc/init.d/mysql restart
Now login to MySQL and you can access the same databases you had before.
Reference : https://stackoverflow.com/questions/1795176/how-to-change-mysql-data-directory
转载于:https://my.oschina.net/geek4j/blog/1535238
MySQL Change Data Directory的更多相关文章
- How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04
16 How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04 PostedJuly 21, 2016 62.1kvie ...
- MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory
Creating file-per-table tablespaces outside the data directory 一. Data Directory 1.应对情况 当数据库所在空间不足的时 ...
- Change MYSQL data directory
For example, change mysql data directory from /var/lib/mysql to /var/data/mysql Step1: Copy the /var ...
- Change the default MySQL data directory with SELinux enabled
转载:https://rmohan.com/?p=4605 Change the default MySQL data directory with SELinux enabled This is a ...
- 启动 mysql 失败 Warning:The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql'
Warning:The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' 这应该是某种情况下导致/usr/ ...
- Mac下启动MySQL出现错误“the /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user”解决
错误如下: Warring the /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user 这应该是某 ...
- MYSQL安装报错 -- 出现Failed to find valid data directory.
运行环境:windows10数据库版本:mysql.8.0.12安装方式:rpm包直接安装 问题描述:mysql初始化的时候找不到对应的数据库存储目录 报错代码: 2018-10-13T03:29:2 ...
- Warning:The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql'
Mac OS X的升级或其他原因可能会导致MySQL启动或开机自动运行时 在MySQL操作面板上会提示“Warning:The /usr/local/mysql/data directory is ...
- 安装mysql时出现initialize specified but the data directory has files in in.Aborting.该如何解决
eclipse中写入sql插入语句时,navicat中显示的出现乱码(???). 在修改eclipse工作空间编码.navicate中的数据库编码.mysql中my.ini中的配置之后还是出现乱码. ...
随机推荐
- 【高并发】什么是ForkJoin?看这一篇就够了!
写在前面 在JDK中,提供了这样一种功能:它能够将复杂的逻辑拆分成一个个简单的逻辑来并行执行,待每个并行执行的逻辑执行完成后,再将各个结果进行汇总,得出最终的结果数据.有点像Hadoop中的MapRe ...
- LeetCode | 289. 生命游戏(原地算法/位运算)
记录dalao的位运算骚操作 根据百度百科 ,生命游戏,简称为生命,是英国数学家约翰·何顿·康威在 1970 年发明的细胞自动机. 给定一个包含 m × n 个格子的面板,每一个格子都可以看成是一个细 ...
- 配置NTP和crontab计划任务
配置NTP网络时间客户端和设置计划任务 3.1问题 本例要求配置虚拟机server0,能够自动校对系统时间.相关信息如下: NTP服务器 ...
- .net 后台调用前台JS函数
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "<script>alert('上 ...
- JAVA debug 断点调试
更多调试参看 https://www.cnblogs.com/yjd_hycf_space/p/7483471.html 先编译好要调试的程序.1.设置断点 选定要设置断点的代码行,在行号的区域后面单 ...
- SQL基础系列(3)-变量、函数、存储过程等
1. 变量 定义变量 DECLARE @a INT 赋值 PRINT @a ) --select 赋值 SELECT @name='zcx' PRINT @name SELECT @name=F ...
- CH5105 Cookies (线性dp)
传送门 解题思路: 贪心的想,贪婪值越大的孩子应该分得更多的饼干,那么先sort一遍在此基础上进行dp.最直观的方向,可以设dp[i][j]为前i个孩子一共分得j块饼干的怨恨最小值.然后转移第i+1个 ...
- CentOS 7 yum安装 k8s 创建Pod一直处于ContainerCreating状态 问题解决
问题描述 使用CentOS7的 yum 包管理器安装了 Kubernetes 集群,使用 kubectl 创建服务成功后,执行 kubectl get pods,发现AGE虽然在不断增加,但状态始终不 ...
- python字符串列表元组序列操作
Table of Contents generated with DocToc python系列-字符串.列表.元组的操作 序列的访问及运算符 序列通用操作 访问单个元素 切片访问一部分元素 序列的复 ...
- EL表达式 -- 比较不错
EL表达式 EL 全名为Expression Language EL 语法很简单,它最大的特点就是使用上很方便.接下来介绍EL主要的语法结构: ${sessionScope.user.sex} 所有E ...