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. .NET Core项目部署到Linux(Centos7)(四)VMware Workstation虚拟机Centos 7安装

    目录 1.前言 2.环境和软件的准备 3.创建.NET Core API项目 4.VMware Workstation虚拟机及Centos 7安装 5.Centos 7安装.NET Core环境 6. ...

  2. Zabbix监控平台

                                                                     Zabbix监控平台 案例1:常用系统监控命令 案例2:部署Zabbi ...

  3. 怎样让scratch里的人物两腿走动

    需要人物角色至少有两个“造型”,表现走路时的两个动作.以默认的“小猫”觉色为例,它有两个“造型”,可以用来表现奔跑的动作. 但是要想让小猫跑起来,需要脚本来实现,简单跑动脚本如下 scratch学习视 ...

  4. String、StringBuffer、StringBuilder葫芦三兄弟

    今年因为疫情的原因,本打算在读研期间好好做项目,写论文,在今年9月份能找个好工作,但现在迟迟不能开学,也无法正常的给导师打工,所以干脆就打算好好准备工(fan)作(wan)的事儿. 接触Java也有好 ...

  5. 【python实现卷积神经网络】padding2D层实现

    代码来源:https://github.com/eriklindernoren/ML-From-Scratch 卷积神经网络中卷积层Conv2D(带stride.padding)的具体实现:https ...

  6. flex实现三列布局

    css3新引入的flex在某些情况下布局非常实用 因为它是弹性盒子所以自适应效果会很棒 不过各项布局方案还是各有优劣 <!DOCTYPE html> <html lang=" ...

  7. linux基础知识点扫描

    1.tty:查看自己的虚拟终端 2.echo "你的服务器已经被我控制,请立刻打钱给我,账号12312312312314123421,否则后果自负!!!"  >  /dev/ ...

  8. echarts多个数据添加多个纵坐标

    在我们echarts开发中,肯定会遇到一个问题.那就是当有多个数据且数据大小差距太大时,就会出现有些数据小到看不到的情况.所以在遇到这种情况时,我通常的解决办法就是给他多加一个坐标轴. option  ...

  9. Linux-设备

    一.在Linux系统中,每个设备都被当成一个文件来对待. 在Linux系统中,几乎所有的硬件设备都在/dev这个目录内.

  10. 不同目录有同名proto文件情况下,protoc生成.cc/.h

    首先先参考一下别人的博客,看完了,看懂了,再回过头来看我下面说的情况. 链接 https://blog.csdn.net/CAir2/article/details/78201572 但是这个也就是基 ...