MySQL Change Data Directory
博客专区 > Geek-S 的博客 > 博客详情
MySQL Change Data Directory
Geek-S 发表于1个月前
MySQL Change Data Directory
  • 发表于 1个月前
  • 阅读 7
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云实验室 1小时搭建人工智能应用,让技术更容易入门 免费体验 >>>   

摘要: MySQL Change Data Directory
  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

标签: MySQL
共有 人打赏支持
粉丝 12
博文 74
码字总数 17560
×
Geek-S
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: