如何将mysql数据库移动到另一个安装点

发布于 2024-07-18 00:49:02 字数 126 浏览 4 评论 0原文

我有一个 MySQL 数据库,它变得越来越大,我想将整个数据库移动到另一个安装点,在那里我有足够的存储空间。 我希望传输当前数据,并将新数据保存到新位置。

软件堆栈:在 FreeBSD 6 上运行的 MySQL 5

I have a MySQL database, it is getting larger and larger and I want to move the whole database to another mount point, where I have enough storage. I want my current data to be transferred, and that new data get saved to the new position.

software stack: MySQL 5 running on FreeBSD 6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

相思故 2024-07-25 00:49:02

当然其他答案也是有效的。 但如果你想保留默认配置,请执行以下操作:

  1. stop mysqld
  2. mv /var/lib/mysql /var/lib/mysql.backup
  3. /var/lib/ 下安装新分区mysql
  4. cp -r /var/lib/mysql.backup /var/lib/mysql
  5. 启动 mysqld

Of course other answers are valid. But if you want to keep the default configuration, do following:

  1. stop mysqld
  2. mv /var/lib/mysql /var/lib/mysql.backup
  3. mount your new partition under /var/lib/mysql
  4. cp -r /var/lib/mysql.backup /var/lib/mysql
  5. start mysqld
北笙凉宸 2024-07-25 00:49:02
  • 停止 mysqld
  • 将 /var/lib/mysql(或 my.cnf 中设置的任何 $datadir)复制到新位置 将
  • 新位置安装在旧 $datadir 下,或者修改文件 my.cnf 中的 MySQL 配置以反映新地点。
  • 启动 mysqld

这并不涉及任何魔法。 ;)
但您应该确保复制 MySQL 文件的所有权限。

  • Stop mysqld
  • Copy /var/lib/mysql (or whatever $datadir in my.cnf was set to) to the new location
  • Either mount the new location under the old $datadir or modify the MySQL configuration in the file my.cnf to reflect the new location.
  • Start mysqld

There's no magic involved. ;)
But you should make sure, that you copy all permissions with the files of MySQL.

暮年慕年 2024-07-25 00:49:02

如果您可以容忍数据库因移动而关闭:

  1. 关闭 MySQL
  2. 将文件 rsync 到新的安装点
    1. 更改mysql.conf以告诉MySQL在哪里可以找到这些文件,或者
    2. 使当前目录成为新目录的符号
  3. 重新启动 MySQL

If you can tolerate the database being down for the move:

  1. Shutdown MySQL
  2. rsync the files to the new mount point
  3. either:
    1. change mysql.conf to tell MySQL where to find the files, or
    2. make the current directory a symlnk to the new one
  4. restart MySQL
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文