1. Stop MySQL using the following command:

    sudo /etc/init.d/mysql stop
  2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:

    sudo cp -R -p /var/lib/mysql /newpath
  3. edit the MySQL configuration file with the following command:

    sudo gedit /etc/mysql/my.cnf   # or perhaps /etc/mysql/mysql.conf.d/mysqld.cnf
  4. Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.

  5. In the terminal, enter the command:

    sudo gedit /etc/apparmor.d/usr.sbin.mysqld
  6. Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.

  7. Save and close the file.

  8. Restart the AppArmor profiles with the command:

    sudo /etc/init.d/apparmor reload
  9. Restart MySQL with the command:

    sudo /etc/init.d/mysql restart
  10. 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的更多相关文章

  1. 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 ...

  2. MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory

    Creating file-per-table tablespaces outside the data directory 一. Data Directory 1.应对情况 当数据库所在空间不足的时 ...

  3. Change MYSQL data directory

    For example, change mysql data directory from /var/lib/mysql to /var/data/mysql Step1: Copy the /var ...

  4. 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 ...

  5. 启动 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/ ...

  6. 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 这应该是某 ...

  7. MYSQL安装报错 -- 出现Failed to find valid data directory.

    运行环境:windows10数据库版本:mysql.8.0.12安装方式:rpm包直接安装 问题描述:mysql初始化的时候找不到对应的数据库存储目录 报错代码: 2018-10-13T03:29:2 ...

  8. 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 ...

  9. 安装mysql时出现initialize specified but the data directory has files in in.Aborting.该如何解决

    eclipse中写入sql插入语句时,navicat中显示的出现乱码(???). 在修改eclipse工作空间编码.navicate中的数据库编码.mysql中my.ini中的配置之后还是出现乱码. ...

随机推荐

  1. docker中使用mysql数据库详解(在局域网访问)

    开发过程中经常需要安装.调试mysql数据库,还需要在各种操作系上安装包依赖,实在是繁琐,因此就研究了一下如何在docker上运行一个mysql镜像,省却了我安装.找依赖的问题. 注:本文所有内容均在 ...

  2. Redis操作,数据库操作

    Redis操作,数据库操作 案例1:源码安装Redis缓存服务 案例2:常用Redis数据库操作指令 案例3:配置Redis主从服务器 1 案例1:源码安装Redis缓存服务 1.1 问题 本案例要求 ...

  3. Scratch 全套学习资料

    链接:https://pan.baidu.com/s/1qX0T2B_zczcLaCCpiRrsnA提取码:xfp8

  4. mysql 聚集函数 count 使用详解

    mysql 聚集函数 count 使用详解 本文将探讨以下问题 1.count(*) . count(n).count(null)与count(fieldName) 2.distinct 与 coun ...

  5. 微信小程序页面跳转的三种方式总结

    原文链接 https://blog.csdn.net/zgmu/article/details/72123329 首先我们了解到,小程序规定页面路径只能有五层,所以我们尽量避免多层级的页面跳转 页面跳 ...

  6. postman 工具接口测试

    一.get:请求多个参数时,需要用&连接 eg:http://api.***.cn/api/user/stu_info?stu_name=小黑&set=女   eg:接口请求参数放在b ...

  7. template_homepage

    homepage用到的方法 使用 {% for ... in ...%}  加 {% endfor %} 实现循环结构 举例:  {% for post in posts %} <p style ...

  8. mysql的事务四个特性以及事务的四个隔离级别

    一.事务四大属性 分别是原子性.一致性.隔离性.持久性. 1.原子性(Atomicity) 原子性是指事务包含的所有操作要么全部成功,要么全部失败回滚,因此事务的操作如果成功就必须要完全应用到数据库, ...

  9. 如何提高你使用windows的逼格(windows用成Linux的赶脚)

    一.准备工作 作为一个整洁而有内涵的人,电脑桌面一定要清洁 二.桌面整洁了,软件怎么打开呢?     方案一 方案二.敲重点   我们可以使用终端指令打开windows安装的任意软件: 打开Windo ...

  10. Pytorch自定义创建BP神经网络

    class BPNet(nn.Module): def __init__(self, in_dim, n_hidden_1, n_hidden_2,\ n_hidden_3, n_hidden_4, ...