登录
首页 >  数据库 >  MySQL

怎么更改mysql数据目录(Ubuntu)

来源:SegmentFault

时间:2023-01-26 08:10:13 107浏览 收藏

来到golang学习网的大家,相信都是编程学习爱好者,希望在这里学习数据库相关编程知识。下面本篇文章就来带大家聊聊《怎么更改mysql数据目录(Ubuntu)》,介绍一下MySQL,希望对大家的知识积累有所帮助,助力实战开发!

  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:

    gedit /etc/mysql/my.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.

原文地址

本篇关于《怎么更改mysql数据目录(Ubuntu)》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于数据库的相关知识,请关注golang学习网公众号!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表